Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1067209ybh; Tue, 10 Mar 2020 13:58:54 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsmrzqiZhVEnjYEr8wGSfPd6y4ql1tmylrFklNrNljEaUMDxkm/SE5z6seCF4uJ5DWWapXq X-Received: by 2002:a9d:70c8:: with SMTP id w8mr19312706otj.144.1583873933999; Tue, 10 Mar 2020 13:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583873933; cv=none; d=google.com; s=arc-20160816; b=ZW2N9OLa3CArypfT+mW3x2Kg2cbfivlD1FF8TpX8KKiJt2I6HuP0lCI3ov4vXyIcpd yIF24J1B3agQBmuyjvm6w1tdrPV/OdnBcdxDHNp8URK89DDQEBk24YRCMDAuLqSQTgN1 Gd0zn9l2JDTi/fgo9yE4aUPdoAIXzsndBjhzhcoN+Rd1DowukYSQ2pXtBIEqeeZFu6cs 0Zm9nV0syYibYOKABatEQHA7NzxFdOIty5dY1A2+A+0T+m8uJRIcbK20zpi7D0KPr0gv rzsvk7pAWd3ol7Aqv54OnmmlFof+1i5ZsUn+0Uy2UTFkwx31BbqpX73s1u56GTc9MlyN CxQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=NSnXjtw6BvnjWDGIhdIRejbxeFIsypmUSM0EVeQ+Uig=; b=SDRDVQcOVxWTCmjGQOR7eHpCkJRU8eLfnOW6OLAGBRppUuuAxkUmb4Sf+rLq8QNl/M 3ta0ov5XlMuKrUPvW1RyaaoZbbZWhb7la+fMXWdrDgxpAgXOyOaw5aXH7ZnzI5V5JnjR UTF2p6QVejlzfoZgRAIDX6mueWVGIW5v9XVxUVBl3s7Nmald+vV0YA24BMUUt7MPKjw4 +F9yHjvQt10t8pyOtYoeDB0VEohjbCKWJtC/b5uE66xuSmFAotG9O1aBXeozx0Rq+3L7 YBagMUavh9d+ws/BpQo3QuEQdEPvmwRBpji10LT8nlVNJjydWbsnlsAbas9OTmosU7M0 +Erg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XNQHeyRL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q25si3822928ota.36.2020.03.10.13.58.35; Tue, 10 Mar 2020 13:58:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XNQHeyRL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726599AbgCJU6A (ORCPT + 99 others); Tue, 10 Mar 2020 16:58:00 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43904 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726380AbgCJU6A (ORCPT ); Tue, 10 Mar 2020 16:58:00 -0400 Received: by mail-pg1-f193.google.com with SMTP id u12so6852571pgb.10 for ; Tue, 10 Mar 2020 13:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=NSnXjtw6BvnjWDGIhdIRejbxeFIsypmUSM0EVeQ+Uig=; b=XNQHeyRLT95Iz7HO7tqkWQ6/sSMwGKo5bd80/1Q/QaJ5M1YExD2yISBVWEW/n3lAUr tkv7AJhIRjzO2Hjw1Eu493BeCu5akkQFw7U5n327J4keqaqVy3NZZOnH0sOQ4c7EAwkY Nfumx3a1xGu9L0OrAtTbJl9mO3bqLw6ZrWiD4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NSnXjtw6BvnjWDGIhdIRejbxeFIsypmUSM0EVeQ+Uig=; b=Zkmv6P4WdQIcCuAMgC68PxJy2HF6ZldtFzcErijyBrtvsIljN9jPMYi4Bm0BSY9iro QQc3KXV47Q1ozEzlGshOe9/nwoMYsltObwP78SlmJ9EDS7XOh8uZsEZQrQCxQJU4CMdX 1SYFJmFjGVl4Kkf193TjKhENkzLfetQJAf058PH0xg0qXlQGLdlZ3yXINW4BEwNQjRlr 78Fgx2dtmet4Q9eWshinTFCgmbTbSZViyyZAqU6nca0wml2MFWO2cmHOlzy6axlfSZ5r lYBBlgrwKOcNScT2OcClo4s56hlFUU/MqEaeeBv2CrZlFk8QUWMhIpRwEUlWKQYuKgE3 Awzw== X-Gm-Message-State: ANhLgQ1eTRJm8BuQMxUpRD/qARljGL0YowwLVxgS4nVGCtjeH3g24eFp E53hipJdySh4MhUy2KRTeRZJlg== X-Received: by 2002:a63:650:: with SMTP id 77mr16314387pgg.201.1583873877277; Tue, 10 Mar 2020 13:57:57 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id d186sm30572689pfc.8.2020.03.10.13.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2020 13:57:56 -0700 (PDT) Date: Tue, 10 Mar 2020 13:57:55 -0700 From: Kees Cook To: Bernd Edlinger Cc: "Eric W. Biederman" , Christian Brauner , Jann Horn , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Greg Kroah-Hartman , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" Subject: Re: [PATCH v2 2/5] exec: Factor unshare_sighand out of de_thread and call it separately Message-ID: <202003101356.A2B9885F17@keescook> References: <87a74xi4kz.fsf@x220.int.ebiederm.org> <87r1y8dqqz.fsf@x220.int.ebiederm.org> <87tv32cxmf.fsf_-_@x220.int.ebiederm.org> <87v9ne5y4y.fsf_-_@x220.int.ebiederm.org> <87k13u5y26.fsf_-_@x220.int.ebiederm.org> <202003101319.BAE7B535A@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 10, 2020 at 09:34:03PM +0100, Bernd Edlinger wrote: > On 3/10/20 9:29 PM, Kees Cook wrote: > > On Sun, Mar 08, 2020 at 04:36:17PM -0500, Eric W. Biederman wrote: > >> > >> This makes the code clearer and makes it easier to implement a mutex > >> that is not taken over any locations that may block indefinitely waiting > >> for userspace. > >> > >> Signed-off-by: "Eric W. Biederman" > >> --- > >> fs/exec.c | 39 ++++++++++++++++++++++++++------------- > >> 1 file changed, 26 insertions(+), 13 deletions(-) > >> > >> diff --git a/fs/exec.c b/fs/exec.c > >> index c3f34791f2f0..ff74b9a74d34 100644 > >> --- a/fs/exec.c > >> +++ b/fs/exec.c > >> @@ -1194,6 +1194,23 @@ static int de_thread(struct task_struct *tsk) > >> flush_itimer_signals(); > >> #endif > > > > Semi-related (existing behavior): in de_thread(), what keeps the thread > > group from changing? i.e.: > > > > if (thread_group_empty(tsk)) > > goto no_thread_group; > > > > /* > > * Kill all other threads in the thread group. > > */ > > spin_lock_irq(lock); > > ... kill other threads under lock ... > > > > Why is the thread_group_emtpy() test not under lock? > > > > A new thread cannot created when only one thread is executing, > right? *face palm* Yes, of course. :) I'm thinking too hard. -- Kees Cook