From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753778AbdGJIyP (ORCPT ); Mon, 10 Jul 2017 04:54:15 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:36109 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753697AbdGJIyM (ORCPT ); Mon, 10 Jul 2017 04:54:12 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Kees Cook Cc: Linus Torvalds , Andy Lutomirski , David Howells , Serge Hallyn , John Johansen , Casey Schaufler , Alexander Viro , Michal Hocko , Ben Hutchings , Hugh Dickins , Oleg Nesterov , "Jason A. Donenfeld" , Rik van Riel , James Morris , Greg Ungerer , Ingo Molnar , Nicolas Pitre , Stephen Smalley , Paul Moore , Vivek Goyal , =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= , Tetsuo Handa , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov References: <1499673451-66160-1-git-send-email-keescook@chromium.org> <1499673451-66160-2-git-send-email-keescook@chromium.org> Date: Mon, 10 Jul 2017 03:46:18 -0500 In-Reply-To: <1499673451-66160-2-git-send-email-keescook@chromium.org> (Kees Cook's message of "Mon, 10 Jul 2017 00:57:24 -0700") Message-ID: <87van0r86d.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1dUUSH-0006qU-0B;;;mid=<87van0r86d.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=67.3.213.87;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18YVyyN59Exyp6WiAQgfX8VOClqhratBZU= X-SA-Exim-Connect-IP: 67.3.213.87 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Kees Cook X-Spam-Relay-Country: X-Spam-Timing: total 186 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 3.0 (1.6%), b_tie_ro: 2.0 (1.1%), parse: 1.17 (0.6%), extract_message_metadata: 2.9 (1.6%), get_uri_detail_list: 0.90 (0.5%), tests_pri_-1000: 6 (3.0%), tests_pri_-950: 1.15 (0.6%), tests_pri_-900: 1.02 (0.5%), tests_pri_-400: 21 (11.6%), check_bayes: 20 (11.0%), b_tokenize: 8 (4.1%), b_tok_get_all: 6 (3.1%), b_comp_prob: 1.87 (1.0%), b_tok_touch_all: 3.3 (1.8%), b_finish: 0.65 (0.4%), tests_pri_0: 136 (73.0%), check_dkim_signature: 0.47 (0.3%), check_dkim_adsp: 2.9 (1.6%), tests_pri_500: 4.3 (2.3%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH v2 1/8] exec: Correct comments about "point of no return" X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org But you miss it. The "point of no return" is the call to de_thread. Or aguably anything in flush_old_exec. Once anything in the current task is modified you can't return an error. It very much does not have anything to do with brpm. It has everything to do with current. > diff --git a/fs/exec.c b/fs/exec.c > index 904199086490..7842ae661e34 100644 > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -1285,7 +1285,14 @@ int flush_old_exec(struct linux_binprm * bprm) > if (retval) > goto out; > > - bprm->mm = NULL; /* We're using it now */ > + /* > + * After clearing bprm->mm (to mark that current is using the > + * prepared mm now), we are at the point of no return. If > + * anything from here on returns an error, the check in > + * search_binary_handler() will kill current (since the mm has > + * been replaced). > + */ > + bprm->mm = NULL; > > set_fs(USER_DS); > current->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD | Eric