public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Mike Kravetz <kravetz@us.ibm.com>
Cc: viro@math.psu.edu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] task name handling in proc fs
Date: Thu, 1 Jul 2004 16:03:35 -0700	[thread overview]
Message-ID: <20040701160335.229cfe03.akpm@osdl.org> (raw)
In-Reply-To: <20040701224215.GC5090@w-mikek2.beaverton.ibm.com>

Mike Kravetz <kravetz@us.ibm.com> wrote:
>
> On Thu, Jul 01, 2004 at 03:19:35PM -0700, Andrew Morton wrote:
> > Mike Kravetz <kravetz@us.ibm.com> wrote:
> > >
> > > --- linux-2.6.7/fs/proc/array.c	Wed Jun 16 05:19:36 2004
> > > +++ linux-2.6.7.ptest/fs/proc/array.c	Thu Jul  1 17:44:14 2004
> > > @@ -97,14 +97,14 @@
> > >  		name++;
> > >  		i--;
> > >  		*buf = c;
> > > -		if (!c)
> > > +		if (!*buf)
> > >  			break;
> > > -		if (c == '\\') {
> > > -			buf[1] = c;
> > > +		if (*buf == '\\') {
> > > +			buf[1] = *buf;
> > >  			buf += 2;
> > >  			continue;
> > >  		}
> > > -		if (c == '\n') {
> > > +		if (*buf == '\n') {
> > >  			buf[0] = '\\';
> > >  			buf[1] = 'n';
> > >  			buf += 2;
> > 
> > What is this code for?
> 
> The code is copying the task name from 'c' to 'buf' one character
> at a time.  It is then 'post processing' the characters.  Currently,
> the post processing is based on the value of c which is part of the
> source string (task->curr).  However, it is possible for the source
> string to change during this copy (think exec).  In such a case I
> think it is better to base the 'post processing' on the character
> that already has been safely been copied to the target string rather
> than the character in the source string which might have changed.

But this just makes it a bit less racy than it used to be.

If we need locking around task->comm (and it seems that we do) then
let's do it.

void get_task_comm(char *buf, struct task_struct *tsk);
void set_task_comm(struct task_struct *tsk, char *buf);

It would be a bit lame to add a new lock for this - probably
task_lock() could be coopted.

  reply	other threads:[~2004-07-01 23:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-01 22:05 [PATCH] task name handling in proc fs Mike Kravetz
2004-07-01 22:19 ` Andrew Morton
2004-07-01 22:42   ` Mike Kravetz
2004-07-01 23:03     ` Andrew Morton [this message]
2004-07-01 23:38       ` Mike Kravetz
2004-07-07 21:52       ` Mike Kravetz
2004-07-07 22:11         ` Andrew Morton
2004-07-07 23:35           ` Mike Kravetz
2004-07-08  2:32             ` Paul Jackson
2004-07-08 17:01               ` Mike Kravetz
2004-07-02  1:27     ` Andrew Rodland

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=20040701160335.229cfe03.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=kravetz@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@math.psu.edu \
    /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