From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31AB0C10DCE for ; Tue, 10 Mar 2020 20:58:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F1F35222C3 for ; Tue, 10 Mar 2020 20:58:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XNQHeyRL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726918AbgCJU6A (ORCPT ); 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-Google-Smtp-Source: ADFU+vu4EeH+yVMv9tpwMaGvHwzGMhYFOuE0iRroLbEdduwZiXXe1msMJtUJMFBKLAERB9nEKnQ+wg== 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