Skip to content

Commit 24962af

Browse files
osalvadorvilardagatorvalds
authored andcommitted
fs, elf: make sure to page align bss in load_elf_library
The current code does not make sure to page align bss before calling vm_brk(), and this can lead to a VM_BUG_ON() in __mm_populate() due to the requested lenght not being correctly aligned. Let us make sure to align it properly. Kees: only applicable to CONFIG_USELIB kernels: 32-bit and configured for libc5. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Oscar Salvador <[email protected]> Reported-by: [email protected] Tested-by: Tetsuo Handa <[email protected]> Acked-by: Kees Cook <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Nicolas Pitre <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent fa8cbda commit 24962af

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

fs/binfmt_elf.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,9 +1259,8 @@ static int load_elf_library(struct file *file)
12591259
goto out_free_ph;
12601260
}
12611261

1262-
len = ELF_PAGESTART(eppnt->p_filesz + eppnt->p_vaddr +
1263-
ELF_MIN_ALIGN - 1);
1264-
bss = eppnt->p_memsz + eppnt->p_vaddr;
1262+
len = ELF_PAGEALIGN(eppnt->p_filesz + eppnt->p_vaddr);
1263+
bss = ELF_PAGEALIGN(eppnt->p_memsz + eppnt->p_vaddr);
12651264
if (bss > len) {
12661265
error = vm_brk(len, bss - len);
12671266
if (error)

0 commit comments

Comments
 (0)