linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Paul Menage <menage@google.com>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Li Zefan <lizf@cn.fujitsu.com>
Subject: Re: [PATCH 3/3] cgroup: fix strstrip() abuse
Date: Fri, 2 Oct 2009 15:01:48 -0700	[thread overview]
Message-ID: <6599ad830910021501s66cfc108r9a109b84b0f658a4@mail.gmail.com> (raw)
In-Reply-To: <20091002173955.5F72.A69D9226@jp.fujitsu.com>

On Fri, Oct 2, 2009 at 1:41 AM, KOSAKI Motohiro
<kosaki.motohiro@jp.fujitsu.com> wrote:
> cgroup_write_X64() and cgroup_write_string() ignore the return
> value of strstrip().
> it makes small inconsistent behavior.
>
> example:
> =========================
>  # cd /mnt/cgroup/hoge
>  # cat memory.swappiness
>  60
>  # echo "59 " > memory.swappiness
>  # cat memory.swappiness
>  59
>  # echo " 58" > memory.swappiness
>  bash: echo: write error: Invalid argument
>
>
> This patch fixes it.
>
> Cc: Li Zefan <lizf@cn.fujitsu.com>
> Cc: Paul Menage <menage@google.com>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>

Acked-by: Paul Menage <menage@google.com>

Thanks - although I think I'd s/abuse/misuse/ in the description.

> ---
>  kernel/cgroup.c |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> Index: b/kernel/cgroup.c
> ===================================================================
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -1710,14 +1710,13 @@ static ssize_t cgroup_write_X64(struct c
>                return -EFAULT;
>
>        buffer[nbytes] = 0;     /* nul-terminate */
> -       strstrip(buffer);
>        if (cft->write_u64) {
> -               u64 val = simple_strtoull(buffer, &end, 0);
> +               u64 val = simple_strtoull(strstrip(buffer), &end, 0);
>                if (*end)
>                        return -EINVAL;
>                retval = cft->write_u64(cgrp, cft, val);
>        } else {
> -               s64 val = simple_strtoll(buffer, &end, 0);
> +               s64 val = simple_strtoll(strstrip(buffer), &end, 0);
>                if (*end)
>                        return -EINVAL;
>                retval = cft->write_s64(cgrp, cft, val);
> @@ -1753,8 +1752,7 @@ static ssize_t cgroup_write_string(struc
>        }
>
>        buffer[nbytes] = 0;     /* nul-terminate */
> -       strstrip(buffer);
> -       retval = cft->write_string(cgrp, cft, buffer);
> +       retval = cft->write_string(cgrp, cft, strstrip(buffer));
>        if (!retval)
>                retval = nbytes;
>  out:
>
>
>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2009-10-02 22:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-02  8:37 [PATCH 1/3] Mark strstrip() as must_check KOSAKI Motohiro
2009-10-02  8:39 ` [PATCH 2/3] Fix strstrip() abuse in elv_iosched_store() KOSAKI Motohiro
2009-10-02  8:41 ` [PATCH 3/3] cgroup: fix strstrip() abuse KOSAKI Motohiro
2009-10-02 22:01   ` Paul Menage [this message]
2009-10-03 12:05     ` KOSAKI Motohiro
2009-10-03 19:15       ` Paul Menage

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6599ad830910021501s66cfc108r9a109b84b0f658a4@mail.gmail.com \
    --to=menage@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lizf@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox