From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 0ACB71F45A for ; Wed, 14 Aug 2019 12:46:11 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=HN7f CGr+p7sBIoJhj0ptAY3aTLWY+yThtOlY+duFKgDaR7eSOvmpLso1l017HcFdT1uw yr9f8ekDYYzMqDUmG5PjCsVIPs8jCiju3IVYTPcKMWfDXgfqwpdQ9eAXETzH9ZNV /mHwtk2MHlpD9mF1DqDEt4pIbK2BR9VaQAheUWs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=ij7pCSYQku 3tne/WIdCad2MTLYA=; b=yiYyPbF8MSehBvLhPkNeFaLGr+zHsGOOoQvkR7WCmo 9OBhqNwdl+C9f4FToh2qTNkOibG1ZZgG3DgmTzMw1YGuVccPvw15pbNuezmCD4S6 oUrxI9kIrpY/r6lsx07Bz92cy6fvc3eMRKuPgn7g+dLkrVCTwxnFw75WsLngrvkC o= Received: (qmail 38601 invoked by alias); 14 Aug 2019 12:46:08 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 38592 invoked by uid 89); 14 Aug 2019 12:46:07 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: youngberry.canonical.com Date: Wed, 14 Aug 2019 14:45:51 +0200 From: Christian Brauner To: Oleg Nesterov Cc: linux-kernel@vger.kernel.org, libc-alpha@sourceware.org, alistair23@gmail.com, ebiederm@xmission.com, arnd@arndb.de, dalias@libc.org, torvalds@linux-foundation.org, adhemerval.zanella@linaro.org, fweimer@redhat.com, palmer@sifive.com, macro@wdc.com, zongbox@gmail.com, akpm@linux-foundation.org, viro@zeniv.linux.org.uk, hpa@zytor.com Subject: Re: [PATCH v1 1/1] waitid: Add support for waiting for the current process group Message-ID: <20190814124551.hnt363g3blhuf2pv@wittgenstein> References: <20190814113822.9505-1-christian.brauner@ubuntu.com> <20190814113822.9505-2-christian.brauner@ubuntu.com> <20190814122909.GA11595@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190814122909.GA11595@redhat.com> User-Agent: NeoMutt/20180716 On Wed, Aug 14, 2019 at 02:29:10PM +0200, Oleg Nesterov wrote: > On 08/14, christian.brauner@ubuntu.com wrote: > > > > case P_PGID: > > type = PIDTYPE_PGID; > > - if (upid <= 0) > > + if (upid < 0) > > return -EINVAL; > > + > > + if (upid == 0) > > + pid = get_pid(task_pgrp(current)); > > this needs rcu lock or tasklist_lock, this can race with another thread > doing sys_setpgid/setsid (see change_pid(PIDTYPE_PGID)). Oh, I naively assumed task_pgrp() would take an rcu lock... kernel/sys.c takes both, i.e. rcu_read_lock(); write_lock_irq(&tasklist_lock); though I think we should be fine with just rcu_read_lock(). setpgid() indicates that it wants to check real_parent and needs the write_lock_irq() because it might change behind its back which we don't care about since we're not changing the pgrp. Christian