From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751963Ab1IBMkh (ORCPT ); Fri, 2 Sep 2011 08:40:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62160 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750860Ab1IBMkg (ORCPT ); Fri, 2 Sep 2011 08:40:36 -0400 Date: Fri, 2 Sep 2011 14:37:06 +0200 From: Oleg Nesterov To: akpm@linux-foundation.org Cc: 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 Message-ID: <20110902123706.GB26764@redhat.com> References: <201109012108.p81L8X0b029484@imap1.linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201109012108.p81L8X0b029484@imap1.linux-foundation.org> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Ben Blum > > 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.