From: Andrew Morton <akpm@linux-foundation.org>
To: Evgeny Kuznetsov <EXT-Eugeny.Kuznetsov@nokia.com>
Cc: menage@google.com, lizf@cn.fujitsu.com,
kamezawa.hiroyu@jp.fujitsu.com, bblum@andrew.cmu.edu,
containers@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, ext-eugeny.kuznetsov@nokia.com
Subject: Re: [PATCH 1/1] cgroups: strcpy destination string overflow
Date: Tue, 5 Oct 2010 12:48:02 -0700 [thread overview]
Message-ID: <20101005124802.989f6214.akpm@linux-foundation.org> (raw)
In-Reply-To: <2acb25707f916de866aa520b1a9f04f0f48c949c.1286193571.git.EXT-Eugeny.Kuznetsov@nokia.com>
On Tue, 5 Oct 2010 12:38:05 +0400
Evgeny Kuznetsov <EXT-Eugeny.Kuznetsov@nokia.com> wrote:
> From: Evgeny Kuznetsov <ext-eugeny.kuznetsov@nokia.com>
>
> Function "strcpy" is used without check for maximum allowed source
> string length and could cause destination string overflow.
> Check for string length is added before using "strcpy".
> Function now is return error if source string length is more than
> a maximum.
>
> Signed-off-by: Evgeny Kuznetsov <EXT-Eugeny.Kuznetsov@nokia.com>
> ---
> kernel/cgroup.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index c9483d8..82bbede 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -1883,6 +1883,8 @@ static int cgroup_release_agent_write(struct cgroup *cgrp, struct cftype *cft,
> const char *buffer)
> {
> BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX);
> + if (strlen(buffer) >= PATH_MAX)
> + return -EINVAL;
> if (!cgroup_lock_live_group(cgrp))
> return -ENODEV;
> strcpy(cgrp->root->release_agent_path, buffer);
I don't think this can happen, because cftype.max_write_len is
PATH_MAX.
But it's pretty unobvious if this is actually true, and the code is
fragile against future changes.
next prev parent reply other threads:[~2010-10-05 19:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-05 8:38 [PATCH 0/1] cgroups: strcpy destination string overflow Evgeny Kuznetsov
2010-10-05 8:38 ` [PATCH 1/1] " Evgeny Kuznetsov
2010-10-05 19:48 ` Andrew Morton [this message]
2010-10-05 19:50 ` 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=20101005124802.989f6214.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=EXT-Eugeny.Kuznetsov@nokia.com \
--cc=bblum@andrew.cmu.edu \
--cc=containers@lists.linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--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