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: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	bblum@andrew.cmu.edu, 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: Fri, 2 Sep 2011 10:15:50 -0400	[thread overview]
Message-ID: <20110902141550.GA24012@unix33.andrew.cmu.edu> (raw)
In-Reply-To: <20110902140015.GA31530@redhat.com>

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.

-- Ben

> 
> On 09/02, Oleg Nesterov wrote:
> >
> > > From: Ben Blum <bblum@andrew.cmu.edu>
> > >
> > > Fix unstable tasklist locking in cgroup_attach_proc.
> > >
> > > According to this thread - https://lkml.org/lkml/2011/7/27/243 - RCU is
> > > not sufficient to guarantee the tasklist is stable w.r.t.  de_thread and
> > > exit.  Taking tasklist_lock for reading, instead of rcu_read_lock, ensures
> > > proper exclusion.
> >
> > I still think we should avoid the global lock.
> >
> > In any case, with tasklist or siglock,
> >
> > > -	rcu_read_lock();
> > > +	read_lock(&tasklist_lock);
> > >  	if (!thread_group_leader(leader)) {
> > >  		/*
> > >  		 * a race with de_thread from another thread's exec() may strip
> > > @@ -2036,7 +2036,7 @@ int cgroup_attach_proc(struct cgroup *cg
> > >  		 * throw this task away and try again (from cgroup_procs_write);
> > >  		 * this is "double-double-toil-and-trouble-check locking".
> > >  		 */
> > > -		rcu_read_unlock();
> > > +		read_unlock(&tasklist_lock);
> > >  		retval = -EAGAIN;
> >
> > this check+comment becomes completely pointless and imho very confusing.
> >
> > Oleg.
> 
> 

  reply	other threads:[~2011-09-02 14:16 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 [this message]
2011-09-02 15:55       ` Oleg Nesterov
2011-09-07 23:59         ` Ben Blum
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=20110902141550.GA24012@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).