Skip to content

Commit e7f7785

Browse files
committed
binfmt: Move install_exec_creds after setup_new_exec to match binfmt_elf
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. Greg Ungerer reports: > I tested the the whole series on non-MMU m68k and non-MMU arm > (exercising binfmt_flat) and it all tested out with no problems, > so for the binfmt_flat changes: Tested-by: Greg Ungerer <[email protected]> Ref: 9f834ec ("binfmt_elf: switch to new creds when switching to new mm") Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Greg Ungerer <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 6a8b55e commit e7f7785

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

arch/x86/ia32/ia32_aout.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ static int load_aout_binary(struct linux_binprm *bprm)
140140
set_personality_ia32(false);
141141

142142
setup_new_exec(bprm);
143+
install_exec_creds(bprm);
143144

144145
regs->cs = __USER32_CS;
145146
regs->r8 = regs->r9 = regs->r10 = regs->r11 = regs->r12 =
@@ -156,8 +157,6 @@ static int load_aout_binary(struct linux_binprm *bprm)
156157
if (retval < 0)
157158
return retval;
158159

159-
install_exec_creds(bprm);
160-
161160
if (N_MAGIC(ex) == OMAGIC) {
162161
unsigned long text_addr, map_size;
163162

fs/binfmt_aout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
162162
set_personality(PER_LINUX);
163163
#endif
164164
setup_new_exec(bprm);
165+
install_exec_creds(bprm);
165166

166167
current->mm->end_code = ex.a_text +
167168
(current->mm->start_code = N_TXTADDR(ex));
@@ -174,7 +175,6 @@ static int load_aout_binary(struct linux_binprm * bprm)
174175
if (retval < 0)
175176
return retval;
176177

177-
install_exec_creds(bprm);
178178

179179
if (N_MAGIC(ex) == OMAGIC) {
180180
unsigned long text_addr, map_size;

fs/binfmt_elf_fdpic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
353353
current->personality |= READ_IMPLIES_EXEC;
354354

355355
setup_new_exec(bprm);
356+
install_exec_creds(bprm);
356357

357358
set_binfmt(&elf_fdpic_format);
358359

@@ -434,7 +435,6 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
434435
current->mm->start_stack = current->mm->start_brk + stack_size;
435436
#endif
436437

437-
install_exec_creds(bprm);
438438
if (create_elf_fdpic_tables(bprm, current->mm,
439439
&exec_params, &interp_params) < 0)
440440
goto error;

fs/binfmt_flat.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ static int load_flat_file(struct linux_binprm *bprm,
541541
/* OK, This is the point of no return */
542542
set_personality(PER_LINUX_32BIT);
543543
setup_new_exec(bprm);
544+
install_exec_creds(bprm);
544545
}
545546

546547
/*
@@ -963,8 +964,6 @@ static int load_flat_binary(struct linux_binprm *bprm)
963964
}
964965
}
965966

966-
install_exec_creds(bprm);
967-
968967
set_binfmt(&flat_format);
969968

970969
#ifdef CONFIG_MMU

0 commit comments

Comments
 (0)