public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	john.stultz@linaro.org
Subject: Re: [PATCH 1/1] coredump: use task comm instead of (unknown)
Date: Fri, 6 May 2011 20:28:26 -0700	[thread overview]
Message-ID: <20110506202826.68850d88.akpm@linux-foundation.org> (raw)
In-Reply-To: <201105071114.CJH64556.FOOVFHOQJSFLtM@I-love.SAKURA.ne.jp>

On Sat, 7 May 2011 11:14:14 +0900 Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:

> Andrew Morton wrote:
> > > char *strncpy(char *dest, const char *src, size_t n)
> > > {
> > > 	size_t len = __strnend(src, n) - src;
> 
> If src was overwritten by prctl(PR_SET_NAME) at this moment (i.e. after len was
> calculated),
> 
> > > 	__builtin_memset(dest + len, 0, n - len);
> > > 	__builtin_memcpy(dest, src, len);
> 
> won't this result in inconsistent copying of src when length of src has changed
> by prctl(PR_SET_NAME)?
> 
> > > 	return dest;
> > > }
> 
> This strncpy() assumes that length of src won't change within the function.
> I thought prctl(PR_SET_NAME) might break such assumption.

PR_SET_NAME uses set_task_comm() which has appropriate locking to
protect against get_task_comm().  

If kernel code directly accesses task->comm without taking task_lock()
then yes, it's racy.


  reply	other threads:[~2011-05-07  3:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4DC0FFAB.1000805@gmail.com>
2011-05-04  7:32 ` [PATCH 1/1] coredump: use task comm instead of (unknown) Jiri Slaby
2011-05-05 22:06   ` Andrew Morton
2011-05-06  6:01     ` Jiri Slaby
2011-05-06 12:26     ` Tetsuo Handa
2011-05-06 19:33       ` Andrew Morton
2011-05-07  2:14         ` Tetsuo Handa
2011-05-07  3:28           ` Andrew Morton [this message]
2011-05-07 15:37             ` Tetsuo Handa

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=20110506202826.68850d88.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=john.stultz@linaro.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    /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