kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serge@hallyn.com>
To: Dan Carpenter <error27@gmail.com>,
	Paul Menage <menage@google.com>, Li Zefan <lizf@cn.fujitsu.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Ben Blum <bblum@andrew.cmu.edu>,
	containers@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] cgroups: save space for the terminator
Date: Mon, 12 Jul 2010 00:10:22 +0000	[thread overview]
Message-ID: <20100712001022.GA6832@hallyn.com> (raw)
In-Reply-To: <20100710105429.GW19184@bicker>

Quoting Dan Carpenter (error27@gmail.com):
> The original code didn't leave enough space for a NULL terminator.
> These strings are copied with strcpy() into fixed length buffers in
> cgroup_root_from_opts().
>  
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Hmm, yes - the fact that kstrndup() allocs len+1 probably threw off
the author of these original lines.  Thanks for spotting this!

Acked-by: Serge E. Hallyn <serge@hallyn.com>


> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 3ac6f5b..a942820 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -1102,7 +1102,7 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
>  			if (opts->release_agent)
>  				return -EINVAL;
>  			opts->release_agent > -				kstrndup(token + 14, PATH_MAX, GFP_KERNEL);
> +				kstrndup(token + 14, PATH_MAX - 1, GFP_KERNEL);
>  			if (!opts->release_agent)
>  				return -ENOMEM;
>  		} else if (!strncmp(token, "name=", 5)) {
> @@ -1123,7 +1123,7 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
>  			if (opts->name)
>  				return -EINVAL;
>  			opts->name = kstrndup(name,
> -					      MAX_CGROUP_ROOT_NAMELEN,
> +					      MAX_CGROUP_ROOT_NAMELEN - 1,
>  					      GFP_KERNEL);
>  			if (!opts->name)
>  				return -ENOMEM;
> _______________________________________________
> Containers mailing list
> Containers@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/containers

  reply	other threads:[~2010-07-12  0:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-10 10:54 [patch] cgroups: save space for the terminator Dan Carpenter
2010-07-12  0:10 ` Serge E. Hallyn [this message]
2010-07-12  0:23 ` KAMEZAWA Hiroyuki

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=20100712001022.GA6832@hallyn.com \
    --to=serge@hallyn.com \
    --cc=akpm@linux-foundation.org \
    --cc=bblum@andrew.cmu.edu \
    --cc=containers@lists.linux-foundation.org \
    --cc=error27@gmail.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=menage@google.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;
as well as URLs for NNTP newsgroup(s).