Skip to content

Commit 7be3cb0

Browse files
keestorvalds
authored andcommitted
binfmt_elf: Do not move brk for INTERP-less ET_EXEC
When brk was moved for binaries without an interpreter, it should have been limited to ET_DYN only. In other words, the special case was an ET_DYN that lacks an INTERP, not just an executable that lacks INTERP. The bug manifested for giant static executables, where the brk would end up in the middle of the text area on 32-bit architectures. Reported-and-tested-by: Richard Kojedzinszky <[email protected]> Fixes: bbdc607 ("binfmt_elf: move brk out of mmap when doing direct loader exec") Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2268419 commit 7be3cb0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/binfmt_elf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,8 @@ static int load_elf_binary(struct linux_binprm *bprm)
11211121
* (since it grows up, and may collide early with the stack
11221122
* growing down), and into the unused ELF_ET_DYN_BASE region.
11231123
*/
1124-
if (IS_ENABLED(CONFIG_ARCH_HAS_ELF_RANDOMIZE) && !interpreter)
1124+
if (IS_ENABLED(CONFIG_ARCH_HAS_ELF_RANDOMIZE) &&
1125+
loc->elf_ex.e_type == ET_DYN && !interpreter)
11251126
current->mm->brk = current->mm->start_brk =
11261127
ELF_ET_DYN_BASE;
11271128

0 commit comments

Comments
 (0)