Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp163601ybk; Fri, 8 May 2020 22:35:11 -0700 (PDT) X-Google-Smtp-Source: APiQypJJDB1textCpJSwMc7+LJVC2gibMeKOcs8rrXOlLQerOo2FiQtymIftH4Z513IDCwLid9JY X-Received: by 2002:a17:906:85d3:: with SMTP id i19mr4669922ejy.153.1589002511268; Fri, 08 May 2020 22:35:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589002511; cv=none; d=google.com; s=arc-20160816; b=p3ZcBnvCD4fprd0zH9yerG74WslOkDdshHQbM16aHaHKXal9Tr3FSzuoaNJeQVWyul G3kWzR1/gqrEUl9nY95yEqAXpXhD8xVU+FYtaSosRySHsuiwRESDdWlUWGdLWx0jK6RQ Ygo8ba2pvkvWD1B4AIQ6foTKUOo3LcM16hidsaunV3f93hfb9UMKwj0fOdZCdYQKKc1v Ok7NLUTzO/M/lbokK3+PLnM+UUPJZaofNehU3oRC/fDOdyQtHoY/Zc8bXPsVe8gTrQhp ZzRdTLBypmtIIPedAeTH/2PAByw87eyD2trYTtu4d+bx25iMw7vOH3DWhHued7w8UxEU cqEQ== 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=McjHFsfMyglxdFz38lGhUm1tNt0prdaFRILR+RgnQNE=; b=mf/XCdJXrX7W09E2ql5yaQSdFmrb+GbA2K92aLaIs5g+qcxR1S/JnT3UmvkA7xMKRw B5q68953JVfIrW1GM9p1V7VpgDYYcpQUTYMjwRaV/fGI6IyEOfSDFc9GPnzTwJUZlO6R P4tQRUVp3S+AJjV/+Hz9pFig3xCMrgkqoi3dik0xLlNfEQ+1Zu1CwsEbbAfSExUwuyiq szEz04NeIKSYLZtW9pNqpecn84bJBnkMzRW8rEUdkLQT7AKNX8hym4sypTs/IzsI3Xn+ eF3XsKsRrZOgMewpwgnz0RMW1Pw+vFHwdeeGAJbJolYh1Hi6anTKzPFISA8hHLpMxeMS Kiwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gjJvzG+5; 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 q11si2274253eju.120.2020.05.08.22.34.47; Fri, 08 May 2020 22:35:11 -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=gjJvzG+5; 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 S1728833AbgEIFbK (ORCPT + 99 others); Sat, 9 May 2020 01:31:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725820AbgEIFbJ (ORCPT ); Sat, 9 May 2020 01:31:09 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A178C061A0C for ; Fri, 8 May 2020 22:31:09 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id k7so261529pjs.5 for ; Fri, 08 May 2020 22:31:09 -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=McjHFsfMyglxdFz38lGhUm1tNt0prdaFRILR+RgnQNE=; b=gjJvzG+5BYX9WeWWRGhrmrGe89rZBPW9DhLd6QVhxuIhYoIUNeXOzRw1XzMcEOGXGQ UJORe9/LSMYQq78oP5uRH6NoLZ0BgkAjfWbDL1D8tTvS9KPAmk5G2GBNIaAv4CgnEWBz TGDxJ6/0VTxGUPrAP7iCKLKp10wQHjOnivZxg= 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=McjHFsfMyglxdFz38lGhUm1tNt0prdaFRILR+RgnQNE=; b=iz6fUS5UYhvIWaQfGUrzIn//rDayqvITdM/PxSJ6MHOIwFqgX+mE6TdvLNF35xGB6Y /O15r1ewwo00QeLeaAJuABvrykWBnkv+tD+gc7BmWjKY3L5kxIISHMkvDstMs0TRmuUj uZiHnF9jZ7HqUrSWSc+PEzbJHj6tlD8hR3ntEdjddeF5VcQxrilyHCxDAJpTBaFBvIja /uaVqYXaHYHbwxaIgMj5TXaqOhqhd+/+9+4AR2uWv9s6OLVjrxPoFacWlgeI4LVW06vS 9TZKUT8EhwbKtI7b49w0fAP6fCwFsAxrJCX11LyH5sGC6YNtA9/tsjDMTQ7gT6lb2Xhc 3Rtw== X-Gm-Message-State: AGi0PuYqb2eI/1ZPnMs7XIu9YKtNsvkptXBWvMXEXN7NDVaNTL5qXhbP zewcrSDup+hX3lqFhcg3WGf5jw== X-Received: by 2002:a17:902:9044:: with SMTP id w4mr5830489plz.83.1589002268808; Fri, 08 May 2020 22:31:08 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id i185sm3487660pfg.14.2020.05.08.22.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2020 22:31:08 -0700 (PDT) Date: Fri, 8 May 2020 22:31:06 -0700 From: Kees Cook To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Oleg Nesterov , Jann Horn , Greg Ungerer , Rob Landley , Bernd Edlinger , linux-fsdevel@vger.kernel.org, Al Viro , Alexey Dobriyan , Andrew Morton Subject: Re: [PATCH 5/6] exec: Move handling of the point of no return to the top level Message-ID: <202005082228.5C0E44CC6@keescook> References: <87h7wujhmz.fsf@x220.int.ebiederm.org> <87sgga6ze4.fsf@x220.int.ebiederm.org> <87y2q25knl.fsf_-_@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87y2q25knl.fsf_-_@x220.int.ebiederm.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 08, 2020 at 01:47:10PM -0500, Eric W. Biederman wrote: > > Move the handing of the point of no return from search_binary_handler > into __do_execve_file so that it is easier to find, and to keep > things robust in the face of change. > > Make it clear that an existing fatal signal will take precedence over > a forced SIGSEGV by not forcing SIGSEGV if a fatal signal is already > pending. This does not change the behavior but it saves a reader > of the code the tedium of reading and understanding force_sig > and the signal delivery code. > > Update the comment in begin_new_exec about where SIGSEGV is forced. > > Keep point_of_no_return from being a mystery by documenting > what the code is doing where it forces SIGSEGV if the > code is past the point of no return. > > Signed-off-by: "Eric W. Biederman" I had to read the code around these changes a bit carefully, but yeah, this looks like a safe cleanup. It is a behavioral change, though (in that in unmasks non-SEGV fatal signals), so I do wonder if something somewhere might notice this, but I'd agree that it's the more robust behavior. Reviewed-by: Kees Cook -- Kees Cook