linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Blum <bblum@andrew.cmu.edu>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Ben Blum <bblum@andrew.cmu.edu>,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	fweisbec@gmail.com, neilb@suse.de, paul@paulmenage.org,
	paulmck@linux.vnet.ibm.com
Subject: Re: + cgroups-more-safe-tasklist-locking-in-cgroup_attach_proc.patch added to -mm tree
Date: Wed, 7 Sep 2011 19:59:31 -0400	[thread overview]
Message-ID: <20110907235931.GA22545@unix33.andrew.cmu.edu> (raw)
In-Reply-To: <20110902155534.GA4595@redhat.com>

On Fri, Sep 02, 2011 at 05:55:34PM +0200, Oleg Nesterov wrote:
> On 09/02, Ben Blum wrote:
> >
> > On Fri, Sep 02, 2011 at 04:00:15PM +0200, Oleg Nesterov wrote:
> > > Forgot to mention, sorry...
> > >
> > > That said, I believe the patch is correct and should fix the problem.
> >
> > Thanks!
> >
> > But I don't think the check becomes pointless? If a sub-thread execs
> > right before read_lock(&tasklist_lock) (but after the find_task_by_vpid
> > in attach_task_by_pid), that causes the case that the comment refers to.
> 
> How so? The comment says:
> 
> 	* a race with de_thread from another thread's exec() may strip
> 	* us of our leadership, making while_each_thread unsafe
> 
> This is not true.

Sorry, the comment is unclear. The reason I think this is necessary is
if de_thread happens, the leader would fall off the thread-group list:

de_thread()
=> release_task(leader)
=> __exit_signal(leader)
=> __unhash_process(leader, false)
=> list_del_rcu(&leader->thread_group)

which is the same list that while_each_thread() iterates over.

and this looks like an unconditionally taken path?

> 
> And. Given that ->group_leader can be changed right after we drop tasklist
> this check is pointless. Yes, it can detect the case when this task_struct
> has nothing to do with this process sometimes, but not in general. (This
> connects to other problems I mentioned).

I agree there is a problem later with the ss->attach(leader) calls.

If the above reasoning is right, though, it's necessary here, and also
guarantees that that the later iteration (in cgroup_attach_proc's "step
3") accurately reflects all threads in the group.

Thanks,
Ben

> 
> IOW, personally I think it would be better to update the patch. But I
> won't insist.
> 
> Oleg.
> 
> 



  reply	other threads:[~2011-09-08  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201109012108.p81L8X0b029484@imap1.linux-foundation.org>
2011-09-02 12:37 ` + cgroups-more-safe-tasklist-locking-in-cgroup_attach_proc.patch added to -mm tree Oleg Nesterov
2011-09-02 14:00   ` Oleg Nesterov
2011-09-02 14:15     ` Ben Blum
2011-09-02 15:55       ` Oleg Nesterov
2011-09-07 23:59         ` Ben Blum [this message]
2011-09-08 17:35           ` Oleg Nesterov
2011-09-08 18:58             ` Ben Blum
2011-09-08 21:31               ` Oleg Nesterov
2011-09-09  2:11                 ` Ben Blum
2011-09-09 16:41                   ` Oleg Nesterov

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=20110907235931.GA22545@unix33.andrew.cmu.edu \
    --to=bblum@andrew.cmu.edu \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=oleg@redhat.com \
    --cc=paul@paulmenage.org \
    --cc=paulmck@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).