public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: john stultz <johnstul@us.ibm.com>
Cc: Arjan van de Ven <arjan@infradead.org>,
	Andi Kleen <andi@firstfloor.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Mike Fulton <fultonm@ca.ibm.com>,
	Sean Foley <Sean_Foley@ca.ibm.com>,
	Darren Hart <dvhltc@us.ibm.com>
Subject: Re: [RFC][PATCH] Add prctl to set sibling thread names
Date: Wed, 21 Oct 2009 19:00:28 -0700	[thread overview]
Message-ID: <20091021190028.623a7f6e.akpm@linux-foundation.org> (raw)
In-Reply-To: <1256172744.4768.22.camel@localhost.localdomain>

On Wed, 21 Oct 2009 17:52:24 -0700 john stultz <johnstul@us.ibm.com> wrote:

> On Wed, 2009-10-21 at 17:48 -0700, Arjan van de Ven wrote:
> > On Wed, 21 Oct 2009 16:21:37 -0700
> > john stultz <johnstul@us.ibm.com> wrote:
> > 
> > > 
> > > Taking a very raw attempt at this, I scratched out the following
> > > simple implementation. I'd appreciate any review or suggestions for
> > > improvements. I'm not at all certain the passing of the thread pid_t
> > > through the unsigned long is valid, for instance, or if
> > > same_thread_group() is the right check to make sure we only change
> > > siblings and not tid from other processes. So any advice on better
> > > approaches would be great.
> > > 
> > > +				return -EINVAL;
> > > +
> > > +			set_task_comm(tsk, comm);
> > 
> > 
> > you're pretty much the first now who touches ->comm from
> > not-the-thread-itself.... are you sure that is safe?
> 
> No, I'm not sure at all :)
> 
> Thanks for pointing this out. I'll see whats needed in set_task_comm().
> 

set_task_comm() is OK.  The problem will be the unwritten rule that
processes can read *their own* ->comm without task_lock(), because nobody
ever alters ->comm apart from tack which owns it.

You've changed that, so all the open-coded accesses to current->comm are
now racy.

Also, you appear to be running set_task_comm() against a task_struct
without holding a reference on that task.  Will a well-timed exit() cause a
modify-after-free?



  reply	other threads:[~2009-10-22  2:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-21 23:21 [RFC][PATCH] Add prctl to set sibling thread names john stultz
2009-10-22  0:28 ` Andi Kleen
2009-10-22  0:42   ` john stultz
2009-10-22  0:44     ` Andi Kleen
2009-10-22  0:48 ` Arjan van de Ven
2009-10-22  0:49   ` Andi Kleen
2009-10-22  2:48     ` Arjan van de Ven
2009-10-24  3:54       ` Andi Kleen
2009-10-26 23:56         ` john stultz
2009-10-22  0:52   ` john stultz
2009-10-22  2:00     ` Andrew Morton [this message]
2009-11-05  2:26       ` KOSAKI Motohiro
2009-11-05  5:17         ` Darren Hart
2009-11-05  5:22           ` KOSAKI Motohiro
2009-11-05  5:36             ` Darren Hart
2009-11-05  5:42               ` KOSAKI Motohiro
2009-11-05 19:11                 ` john stultz
     [not found]                 ` <OF5EE04242.D2B67AF2-ON85257665.0064683D-85257665.0068209E@ca.ibm.com>
2009-11-10  5:27                   ` KOSAKI Motohiro
2009-11-10 20:16                     ` john stultz
2009-11-11  0:04                       ` KOSAKI Motohiro
  -- strict thread matches above, loose matches on Subject: below --
2009-11-05 19:03 Sean Foley

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=20091021190028.623a7f6e.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=Sean_Foley@ca.ibm.com \
    --cc=andi@firstfloor.org \
    --cc=arjan@infradead.org \
    --cc=dvhltc@us.ibm.com \
    --cc=fultonm@ca.ibm.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    /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