linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs, elf: Make sure to page align bss in load_elf_library
@ 2018-07-05 14:55 osalvador
  2018-07-05 15:44 ` Kees Cook
  0 siblings, 1 reply; 5+ messages in thread
From: osalvador @ 2018-07-05 14:55 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: linux-mm, linux-kernel, mhocko, penguin-kernel, keescook,
	nicolas.pitre, Oscar Salvador

From: Oscar Salvador <osalvador@suse.de>

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.

Signed-off-by: Oscar Salvador <osalvador@suse.de>
Tested-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Reported-by: syzbot+5dcb560fe12aa5091c06@syzkaller.appspotmail.com
---
 fs/binfmt_elf.c | 5 ++---
 1 file 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)
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-07-06 22:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-05 14:55 [PATCH] fs, elf: Make sure to page align bss in load_elf_library osalvador
2018-07-05 15:44 ` Kees Cook
2018-07-06  7:13   ` Oscar Salvador
2018-07-06 19:23     ` Kees Cook
2018-07-06 22:55   ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).