Commit 24962af7 authored by Oscar Salvador's avatar Oscar Salvador Committed by Linus Torvalds

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: default avatarOscar Salvador <>
Tested-by: default avatarTetsuo Handa <>
Acked-by: default avatarKees Cook <>
Cc: Michal Hocko <>
Cc: Nicolas Pitre <>
Cc: <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent fa8cbda8
......@@ -1259,9 +1259,8 @@ static int load_elf_library(struct file *file)
goto out_free_ph;
len = ELF_PAGESTART(eppnt->p_filesz + eppnt->p_vaddr +
bss = eppnt->p_memsz + eppnt->p_vaddr;
len = ELF_PAGEALIGN(eppnt->p_filesz + eppnt->p_vaddr);
bss = ELF_PAGEALIGN(eppnt->p_memsz + eppnt->p_vaddr);
if (bss > len) {
error = vm_brk(len, bss - len);
if (error)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment