Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4524404ybb; Tue, 7 Apr 2020 09:06:55 -0700 (PDT) X-Google-Smtp-Source: APiQypLDe+fDDBMC2kE2J47tHuzi89OxzpvhOPFWbbQTbdlOLm0rU0FZROWVJ6/Ous054/FCMSqc X-Received: by 2002:aca:5e0b:: with SMTP id s11mr2200332oib.111.1586275615725; Tue, 07 Apr 2020 09:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586275615; cv=none; d=google.com; s=arc-20160816; b=VHV3EGKziGg2c/9rqZDHXovW6AjEIKTv43ppM39lONP0cKfQpAc6cLc5gaZpnXcsZQ 6rjD2Dx6Qca3bd/RPKNhiUO+VMdE/etDV45QXBRo061echkBw8pBxKPJbZUaY/U5alMM cdNrGS2ubjiQUrDpMf8h+Wg9Be/kTW/cy3rLT6w9uEbv5Mh/lynypZm7rKvgK0qBFeFY innV4ZT/hOfPA4twBCzhF7ldnjhsAz+i/lDlqHKLhdKyrK3+nP58kRDbwaOYXK/4yy+j R0h3z8FpSy6ik7/LJEdJXf0IjXuFEi9hyWvOAhhB5fS/lXrodqp/RP4hKIhF8ybwpZSo d/iw== 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=gP729yExvsKwcKrE86VBUvEUivRuAU1I4cifk756xg8=; b=EdQMFQy7hoioqKs0f30uFFEl6/9RZml05IG0HZbcGVpx05jss1HRoAULcW43HuGMBI X5F1/IjGWcP8cM5CjOz84HSMUSB4m00r1qOtXmeUsHHd25SXf9nZADZAF6wQ7SILTMq0 RXitL5TYOoODI7Oze7gu7frGsG6u6OnoUxiegeiRvpO0Yu1nULVGu0dzvwVX7u7VtaYk bcVgW+MFUwjHtWraaL/4TGYJdApExgnk/Kd76YxwxhqwB//NwYeKvvDwAAVhk56f8rJ+ +y9ewGc39JKXe4uhmOk3ypMyN78hBaJpKOYlnoq+2T58cXUIDJNLvhR8F0IONBIPmrQ5 FH4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="BiT/yyVr"; 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 26si823591oiz.107.2020.04.07.09.06.31; Tue, 07 Apr 2020 09:06:55 -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="BiT/yyVr"; 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 S1728060AbgDGQDu (ORCPT + 99 others); Tue, 7 Apr 2020 12:03:50 -0400 Received: from mail-pj1-f66.google.com ([209.85.216.66]:54820 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728000AbgDGQDt (ORCPT ); Tue, 7 Apr 2020 12:03:49 -0400 Received: by mail-pj1-f66.google.com with SMTP id np9so940422pjb.4 for ; Tue, 07 Apr 2020 09:03:48 -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=gP729yExvsKwcKrE86VBUvEUivRuAU1I4cifk756xg8=; b=BiT/yyVr1rSfof6VFqWXygsiJDCQsZIVl3d4oHMX1AlwZu2InJRMzINblucNVGW/ZH t+PA9lgM0DmQMakMUPj4R/C/CPo85Zx7iBKrQHz14noUlbYVtQ2CR0tcbxK52eUp/0by XbWcQl93c78Jk4nzonwajBC96ypn5aCIxRxEE= 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=gP729yExvsKwcKrE86VBUvEUivRuAU1I4cifk756xg8=; b=Iy8b9DD03rUMAlD1XyTl6vmxcNyzzXI7pXyzgGKpZkoORAM2qCZZlSVfvRCA+rnYoU PHn+7QJtb0TUyOsJF4BZ2yI4Y0IIWXA7zjDamcrcPQ/ZWn9ydhi7UBkU1nwC/P9XBfjz geOp+tf+8u4AoB8ILXeHHWf+Kt2rADpK2ORRfk0V69murrm5AgqLL/b3Q9k6ntPbQzZP 5MD6Gc37bpW41HiLTsKVLl4Ah6BxYYaLO0nkb/PjN1hhCRq5LEhLPGB+bQf22lqFCWDG xYBZJVteS0lScvllWd6oxjxnDo/bJgTi3xHpg73pKUfqr0eD9XbQ2/wRcQMWO8c/Buna /lPw== X-Gm-Message-State: AGi0Puae1hpHjGkfWthLgHbGQJUpmgSd7NCjeoYTjsKYI7Be9gSfp7hh oYeZGTNyBYP0zeEXpVrFwCv8cA== X-Received: by 2002:a17:902:6acc:: with SMTP id i12mr3051101plt.61.1586275428262; Tue, 07 Apr 2020 09:03:48 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id nh14sm2014218pjb.17.2020.04.07.09.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 09:03:47 -0700 (PDT) Date: Tue, 7 Apr 2020 09:03:46 -0700 From: Kees Cook To: "Eric W. Biederman" Cc: Linus Torvalds , Bernd Edlinger , Linux Kernel Mailing List , Alexey Gladkov , Oleg Nesterov , Jann Horn , Christian Brauner Subject: Re: [PATCH 3/3] exec: Rename the flag called_exec_mmap point_of_no_return Message-ID: <202004070903.CC08A70A@keescook> References: <87blobnq02.fsf@x220.int.ebiederm.org> <87lfnda3w3.fsf@x220.int.ebiederm.org> <87wo6s3wxd.fsf_-_@x220.int.ebiederm.org> <87d08k3wt4.fsf_-_@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87d08k3wt4.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 Mon, Apr 06, 2020 at 08:32:23PM -0500, Eric W. Biederman wrote: > > Update the comments and make the code easier to understand by > renaming this flag. > > Signed-off-by: "Eric W. Biederman" I like it, yes! Acked-by: Kees Cook -Kees > --- > fs/exec.c | 12 ++++++------ > include/linux/binfmts.h | 6 +++--- > 2 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/fs/exec.c b/fs/exec.c > index 28c87020da9b..a61987d6dc33 100644 > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -1300,12 +1300,12 @@ int flush_old_exec(struct linux_binprm * bprm) > goto out; > > /* > - * After setting bprm->called_exec_mmap (to mark that current is > - * using the prepared mm now), we have nothing left of the original > - * process. If anything from here on returns an error, the check > - * in search_binary_handler() will SEGV current. > + * With the new mm installed it is completely impossible to > + * fail and return to the original process. If anything from > + * here on returns an error, the check in > + * search_binary_handler() will SEGV current. > */ > - bprm->called_exec_mmap = 1; > + bprm->point_of_no_return = true; > bprm->mm = NULL; > > #ifdef CONFIG_POSIX_TIMERS > @@ -1694,7 +1694,7 @@ int search_binary_handler(struct linux_binprm *bprm) > > read_lock(&binfmt_lock); > put_binfmt(fmt); > - if (retval < 0 && bprm->called_exec_mmap) { > + if (retval < 0 && bprm->point_of_no_return) { > /* we got to flush_old_exec() and failed after it */ > read_unlock(&binfmt_lock); > force_sigsegv(SIGSEGV); > diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h > index 6f564b9ad882..8f479dad7931 100644 > --- a/include/linux/binfmts.h > +++ b/include/linux/binfmts.h > @@ -46,10 +46,10 @@ struct linux_binprm { > */ > secureexec:1, > /* > - * Set by flush_old_exec, when exec_mmap has been called. > - * This is past the point of no return. > + * Set when errors can no longer be returned to the > + * original userspace. > */ > - called_exec_mmap:1; > + point_of_no_return:1; > #ifdef __alpha__ > unsigned int taso:1; > #endif > -- > 2.25.0 > -- Kees Cook