All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Rientjes <rientjes@google.com>,
	John Stultz <johnstul@us.ibm.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [patch] fs, proc: truncate /proc/pid/comm writes to first TASK_COMM_LEN bytes
Date: Tue, 09 Apr 2013 13:11:23 -0700	[thread overview]
Message-ID: <516475EB.7030508@linaro.org> (raw)
In-Reply-To: <20130409130306.4e24a5dd1773c99eaf356db8@linux-foundation.org>

On 04/09/2013 01:03 PM, Andrew Morton wrote:
>> cc: John Stultz <johnstul@us.ibm.com>
> I don't know if that address still works.

No, that email is no longer active. Thanks for noticing this.


> From: David Rientjes <rientjes@google.com>
> Subject: fs, proc: truncate /proc/pid/comm writes to first TASK_COMM_LEN bytes
>
> Currently, a write to a procfs file will return the number of bytes
> successfully written.  If the actual string is longer than this, the
> remainder of the string will not be be written and userspace will complete
> the operation by issuing additional write()s.
>
> Hence
>
> 	$ echo -n "abcdefghijklmnopqrs" > /proc/self/comm
>
> results in
>
> 	$ cat /proc/$$/comm
> 	pqrs
>
> since the final four bytes were written with a second write() since
> TASK_COMM_LEN == 16.  This is obviously an undesired result and not
> equivalent to prctl(PR_SET_NAME).  The implementation should not need to
> know the definition of TASK_COMM_LEN.

That's embarrassing, thanks for catching it!


> This patch truncates the string to the first TASK_COMM_LEN bytes and
> returns the bytes written as the length of the string written so the
> second write() is suppressed.
>
> 	$ cat /proc/$$/comm
> 	abcdefghijklmno
>
> Signed-off-by: David Rientjes <rientjes@google.com>
> Cc: John Stultz <john.stultz@linaro.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Acked-by: John Stultz <john.stultz@linaro.org>

      reply	other threads:[~2013-04-09 20:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-09  1:55 [patch] fs, proc: truncate /proc/pid/comm writes to first TASK_COMM_LEN bytes David Rientjes
2013-04-09 20:03 ` Andrew Morton
2013-04-09 20:11   ` John Stultz [this message]

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=516475EB.7030508@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=akpm@linux-foundation.org \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rientjes@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.