Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1818650ybj; Wed, 6 May 2020 06:02:36 -0700 (PDT) X-Google-Smtp-Source: APiQypKKA68Mu/1YRweS8GSSZYacSF7yi+xXcP78TgfTSXiZ+aATNOvxsoTHhfYdAo4l0jqtE7tm X-Received: by 2002:a50:f61c:: with SMTP id c28mr6386559edn.365.1588770156605; Wed, 06 May 2020 06:02:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588770156; cv=none; d=google.com; s=arc-20160816; b=CnvXhJovt+7l9F2uodzigp7YIR1LtILBT8xh1GMHGw2FUVmVtSfGoUrtPXh1dbfHyp KaVUKnBli2RX/ml2bSzxjDe54j7kML+UwAMcIGF8FHWByVtv2rg6uu8rypmASKrVwdd9 J0fl/6Vi1D4JsERH6Zs0D+1Ace4kdsADGKe/OdJgOIuis0TLAdvjlzg6J8kkjo5UaGFa SPrib0Zwiav0S6FyAlsspXRipRrqUCHG0v2UAvKWJ/6N/NZQIo7SoguAjyvkMCdY1Agx cWZUizx3RNZXz8zgX73fGCxmmzB6h8OHSsdVHtzKmWCJUumcUGD08EltDvDCpoQlxvTV nmKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from; bh=df1Vp0k6sgGB9LWWQWlQkYwfgUi7qQn188z8sZc4fG8=; b=jfjSWkPgcjyAKO8GwlSJVbjjNwC67W6vmmUa4x2dyVOi2bWBP676mmHiabOlOGMUof 579ant7yJfGiz/JSKaCnXtCrBHcwJrOyjFMdETYtUCAJDbAHEmmbn3XWxzNQCHj82lzj 43Q0MPIv7AslltWjAzvZVh8bUamn4/MYE7tCkIhfcUNfqcErR+MKW/3bmY/sNWCL9b1J WexwwM4xBQhStFK9GjOYFQIqdgFue2nfTVw57VpTyt6ALAFvrQVA9Q/zpMJ+cKHm82PL lF4mTTLBevnkpIBdvmZOqKe46Zsdxd+bRyD54M6xn9OILpO+r/nOJp+jE3gUg50NCD+y C4Og== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si1199419ejy.137.2020.05.06.06.02.07; Wed, 06 May 2020 06:02:36 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728653AbgEFNA1 (ORCPT + 99 others); Wed, 6 May 2020 09:00:27 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:39120 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727964AbgEFNA1 (ORCPT ); Wed, 6 May 2020 09:00:27 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out03.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jWJey-0007Bg-TN; Wed, 06 May 2020 07:00:24 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1jWJey-00061w-1F; Wed, 06 May 2020 07:00:24 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Greg Ungerer Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Oleg Nesterov , Jann Horn , Kees Cook , Rob Landley , Bernd Edlinger , linux-fsdevel@vger.kernel.org, Al Viro , Alexey Dobriyan , Andrew Morton References: <87h7wujhmz.fsf@x220.int.ebiederm.org> <87bln2jhki.fsf@x220.int.ebiederm.org> Date: Wed, 06 May 2020 07:56:59 -0500 In-Reply-To: (Greg Ungerer's message of "Wed, 6 May 2020 22:42:42 +1000") Message-ID: <87v9l9dxwk.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1jWJey-00061w-1F;;;mid=<87v9l9dxwk.fsf@x220.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19W5a9a8zm+g2O6M8Y98Fe+NXQMQUxKUZo= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa07.xmission.com X-Spam-Level: *** X-Spam-Status: No, score=3.2 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,LotsOfNums_01,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01, XMNoVowels,XMSubLong autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 1.2 LotsOfNums_01 BODY: Lots of long strings of numbers * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 0; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: ; sa07 0; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ***;Greg Ungerer X-Spam-Relay-Country: X-Spam-Timing: total 450 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 10 (2.2%), b_tie_ro: 9 (1.9%), parse: 1.16 (0.3%), extract_message_metadata: 16 (3.6%), get_uri_detail_list: 2.5 (0.5%), tests_pri_-1000: 22 (4.9%), tests_pri_-950: 1.20 (0.3%), tests_pri_-900: 0.99 (0.2%), tests_pri_-90: 79 (17.6%), check_bayes: 77 (17.2%), b_tokenize: 10 (2.3%), b_tok_get_all: 8 (1.8%), b_comp_prob: 2.4 (0.5%), b_tok_touch_all: 53 (11.8%), b_finish: 0.89 (0.2%), tests_pri_0: 301 (67.0%), check_dkim_signature: 0.55 (0.1%), check_dkim_adsp: 2.1 (0.5%), poll_dns_idle: 0.51 (0.1%), tests_pri_10: 2.6 (0.6%), tests_pri_500: 12 (2.8%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 1/7] binfmt: Move install_exec_creds after setup_new_exec to match binfmt_elf 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Greg Ungerer writes: > One small nit: Good point. > On 6/5/20 5:41 am, Eric W. Biederman wrote: >> In 2016 Linus moved install_exec_creds immediately after >> setup_new_exec, in binfmt_elf as a cleanup and as part of closing a >> potential information leak. >> >> Perform the same cleanup for the other binary formats. >> >> Different binary formats doing the same things the same way makes exec >> easier to reason about and easier to maintain. >> >> The binfmt_flagt bits were tested by Greg Ungerer > ^^^^^ > flat > > Regards > Greg > > >> Ref: 9f834ec18def ("binfmt_elf: switch to new creds when switching to new mm") >> Signed-off-by: "Eric W. Biederman" >> --- >> arch/x86/ia32/ia32_aout.c | 3 +-- >> fs/binfmt_aout.c | 2 +- >> fs/binfmt_elf_fdpic.c | 2 +- >> fs/binfmt_flat.c | 3 +-- >> 4 files changed, 4 insertions(+), 6 deletions(-) >> >> diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c >> index 9bb71abd66bd..37b36a8ce5fa 100644 >> --- a/arch/x86/ia32/ia32_aout.c >> +++ b/arch/x86/ia32/ia32_aout.c >> @@ -140,6 +140,7 @@ static int load_aout_binary(struct linux_binprm *bprm) >> set_personality_ia32(false); >> setup_new_exec(bprm); >> + install_exec_creds(bprm); >> regs->cs = __USER32_CS; >> regs->r8 = regs->r9 = regs->r10 = regs->r11 = regs->r12 = >> @@ -156,8 +157,6 @@ static int load_aout_binary(struct linux_binprm *bprm) >> if (retval < 0) >> return retval; >> - install_exec_creds(bprm); >> - >> if (N_MAGIC(ex) == OMAGIC) { >> unsigned long text_addr, map_size; >> diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c >> index 8e8346a81723..ace587b66904 100644 >> --- a/fs/binfmt_aout.c >> +++ b/fs/binfmt_aout.c >> @@ -162,6 +162,7 @@ static int load_aout_binary(struct linux_binprm * bprm) >> set_personality(PER_LINUX); >> #endif >> setup_new_exec(bprm); >> + install_exec_creds(bprm); >> current->mm->end_code = ex.a_text + >> (current->mm->start_code = N_TXTADDR(ex)); >> @@ -174,7 +175,6 @@ static int load_aout_binary(struct linux_binprm * bprm) >> if (retval < 0) >> return retval; >> - install_exec_creds(bprm); >> if (N_MAGIC(ex) == OMAGIC) { >> unsigned long text_addr, map_size; >> diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c >> index 240f66663543..6c94c6d53d97 100644 >> --- a/fs/binfmt_elf_fdpic.c >> +++ b/fs/binfmt_elf_fdpic.c >> @@ -353,6 +353,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) >> current->personality |= READ_IMPLIES_EXEC; >> setup_new_exec(bprm); >> + install_exec_creds(bprm); >> set_binfmt(&elf_fdpic_format); >> @@ -434,7 +435,6 @@ static int load_elf_fdpic_binary(struct linux_binprm >> *bprm) >> current->mm->start_stack = current->mm->start_brk + stack_size; >> #endif >> - install_exec_creds(bprm); >> if (create_elf_fdpic_tables(bprm, current->mm, >> &exec_params, &interp_params) < 0) >> goto error; >> diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c >> index 831a2b25ba79..1a1d1fcb893f 100644 >> --- a/fs/binfmt_flat.c >> +++ b/fs/binfmt_flat.c >> @@ -541,6 +541,7 @@ static int load_flat_file(struct linux_binprm *bprm, >> /* OK, This is the point of no return */ >> set_personality(PER_LINUX_32BIT); >> setup_new_exec(bprm); >> + install_exec_creds(bprm); >> } >> /* >> @@ -963,8 +964,6 @@ static int load_flat_binary(struct linux_binprm *bprm) >> } >> } >> - install_exec_creds(bprm); >> - >> set_binfmt(&flat_format); >> #ifdef CONFIG_MMU >>