aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOscar Salvador <[email protected]>2018-07-13 16:59:13 -0700
committerLinus Torvalds <[email protected]>2018-07-14 11:11:10 -0700
commit24962af7e1041b7e50c1bc71d8d10dc678c556b5 (patch)
treebd8ad1a349422c13872dfc60a8c697fd2585590b
parentfa8cbda88db12e632a8987c94b66f5caf25bcec4 (diff)
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]>
-rw-r--r--fs/binfmt_elf.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 0ac456b52bdd..816cc921cf36 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -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 +
- ELF_MIN_ALIGN - 1);
- 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)