Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1684378pxv; Fri, 25 Jun 2021 20:36:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzX5sZD05wbSjwErGM/lBWvdLe1iAyMBrJKf7MLCmFNbRDK+mOTCDkfZU28KiagSXFgZvG X-Received: by 2002:a6b:7617:: with SMTP id g23mr11533853iom.63.1624678572573; Fri, 25 Jun 2021 20:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624678572; cv=none; d=google.com; s=arc-20160816; b=XWtVWxT8xsi0Gr3QkcYVjHORBbVj0962S3qfwI1uy5fZLmFYLrPlZvbkc3QuGbfU6i zqI+Wt6cbvRXl59FzfWFnqGXliH9USglSkdH42mLP5rnFfhiXwpBkdF/dfIvBXYheQ9G rUyuYCvSOwsQJF3qep+uah6igg016/IgXOycmb1Ts6z/fWzHAYxd4xo4cYbEKzSMoLjO P0VwyzMt3CHo8ywU+w7CQaMf4FhP9yFhKU4dttgfcBJ6IrqWxdsQPamXygNt4ZIa91Vv NedOBzJQYRpQZwFncFQzEl4SyqRtK3wlKpJYM9MblOciXh/zwCr2ujlTcd81TGN3nXon tm+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aUhvmz2IAighG804GQ35EBkkFq5G6bi3JzTCxCLPv0E=; b=hdIFH8jkw7fB17m8shJxTjRLCq95kcI4afEVrVFNdUgNi1gPSPmTkMpWvUdcQBOl0G 7ljs6E4lUk6vmF9aR3sxbOaSE4Cn+pjYsyV2lFeADIFl53fKIUlxmv3EaBmtboPhsi6O ricWZKyFXODGC9oNfoN1XDR3Yj+XMPhvJrOIJY9FS0/L8JaU7Nor7lNYseyd4xOVcb3J KK8WMmIaj8fwiyOnj2Eg/dnaurvgnJsJEkpv5Y6NOYcoHIQ/yaz3dVSikl1aI6hxVXMc ZROxa1PwuIjTjAGhPpwlKOV0zfH1WL8P7kkwuGjo4L63uUduM0fbNa54J6eRsD3XPsSJ 6LIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jQhfIeYg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id g6si8627983iow.9.2021.06.25.20.35.58; Fri, 25 Jun 2021 20:36:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jQhfIeYg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S229878AbhFZDhc (ORCPT + 99 others); Fri, 25 Jun 2021 23:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbhFZDh3 (ORCPT ); Fri, 25 Jun 2021 23:37:29 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB15C061768 for ; Fri, 25 Jun 2021 20:35:06 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id m17so5705343plx.7 for ; Fri, 25 Jun 2021 20:35:06 -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=aUhvmz2IAighG804GQ35EBkkFq5G6bi3JzTCxCLPv0E=; b=jQhfIeYg/XK/RbrcxRHqUnVapM962lRzN/PRvFhV2DZYDFbKdC7vhV1PUaQsJn6C2u wc+lSbUOtv47V7AjIimm25dFBpNDIJF/gjwNyux0Zp3DXmVZ+9n9jYRDF4LhGOCQBu/7 W3DUA2b9WyKlpfNECqM9x3zozs9kmMB/qRga4= 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=aUhvmz2IAighG804GQ35EBkkFq5G6bi3JzTCxCLPv0E=; b=uj1mRBdqJnb+uP3Ryem6uaUBeOETL4YKijQ9TbNGpBSdo5wb4u27FfTejYr65FJ3Rw T0qFKk05IJwsoc7O3IOsWUx8n627t9YR4X8dwCK/6PJSXqEbWjz8sJKUtu9npw5f5vSD /S7EK8OP+MJnDliVQRD++60fXiiMxAbER68pfgB6JYQORO1bB8koU57HKclcRgu56Qy5 /mka8As1kKHWCttEou5ECzvgx2LLTbbLu6XMHEaJsvDY/ZnaMckB8q6UcBynii8/lYbK RMc3tsGrXT8ROifuQqLygn4aqcI81iMONZp5BSWu5CqUeGSM0YzQ4LML7vNZJBhcpSeM OLNQ== X-Gm-Message-State: AOAM532/1IBkQbVvcu0NvEJJp7P9ZlLh5EjVFFuuNNBOT5cPA6/buRxl VaSKK1yG25eiL4rXG6tKpPKSZQ== X-Received: by 2002:a17:90a:4d88:: with SMTP id m8mr24251849pjh.169.1624678506089; Fri, 25 Jun 2021 20:35:06 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c24sm7160497pfd.167.2021.06.25.20.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 20:35:05 -0700 (PDT) Date: Fri, 25 Jun 2021 20:35:04 -0700 From: Kees Cook To: "Eric W. Biederman" Cc: Linus Torvalds , Al Viro , Michael Schmitz , linux-arch , Jens Axboe , Oleg Nesterov , Linux Kernel Mailing List , Richard Henderson , Ivan Kokshaysky , Matt Turner , alpha , Geert Uytterhoeven , linux-m68k , Arnd Bergmann , Ley Foon Tan , Tejun Heo Subject: Re: [PATCH 5/9] signal/group_exit: Use start_group_exit in place of do_group_exit Message-ID: <202106252026.E8C5393@keescook> References: <87a6njf0ia.fsf@disp2133> <87tulpbp19.fsf@disp2133> <87zgvgabw1.fsf@disp2133> <875yy3850g.fsf_-_@disp2133> <87a6nf6q97.fsf_-_@disp2133> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87a6nf6q97.fsf_-_@disp2133> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 24, 2021 at 02:01:40PM -0500, Eric W. Biederman wrote: > > Make thread exiting uniform by causing all threads to pass through > get_signal when they are exiting. This simplifies the analysis > of sychronization during exit and guarantees that all full set > of registers will be available for ptrace to examine for > threads that stop at PTRACE_EVENT_EXIT. Yeah, cool. I do like making the process lifetime more sensible here. It always threw me that do_exit*() just stopped execution. :) For future me, can you add a comment on start_group_exit() that mentions where final process death happens? > > Signed-off-by: "Eric W. Biederman" > --- > kernel/exit.c | 4 ++-- > kernel/seccomp.c | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/kernel/exit.c b/kernel/exit.c > index fd1c04193e18..921519d80b56 100644 > --- a/kernel/exit.c > +++ b/kernel/exit.c > @@ -931,8 +931,8 @@ do_group_exit(int exit_code) > */ > SYSCALL_DEFINE1(exit_group, int, error_code) > { > - do_group_exit((error_code & 0xff) << 8); > - /* NOTREACHED */ > + start_group_exit((error_code & 0xff) << 8); > + /* get_signal will call do_exit */ > return 0; "0" feels weird here, but I can't think of any better "fail closed" error code here. > } > > diff --git a/kernel/seccomp.c b/kernel/seccomp.c > index 5301eca670a0..b1c06fd1b205 100644 > --- a/kernel/seccomp.c > +++ b/kernel/seccomp.c > @@ -1250,7 +1250,7 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd, > if (action == SECCOMP_RET_KILL_THREAD) > do_exit(SIGSYS); > else > - do_group_exit(SIGSYS); > + start_group_exit(SIGSYS); This could use a similar comment to the syscall's comment, just so I don't panic when I read this code in like 3 years. ;) Otherwise, yeah, looks good. -Kees > } > return -1; > } > -- > 2.20.1 > -- Kees Cook