[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180705145539.9627-1-osalvador@techadventures.net>
Date: Thu, 5 Jul 2018 16:55:39 +0200
From: osalvador@...hadventures.net
To: linux-fsdevel@...r.kernel.org
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org, mhocko@...e.com,
penguin-kernel@...ove.sakura.ne.jp, keescook@...omium.org,
nicolas.pitre@...aro.org, Oscar Salvador <osalvador@...e.de>
Subject: [PATCH] fs, elf: Make sure to page align bss in load_elf_library
From: Oscar Salvador <osalvador@...e.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@...e.de>
Tested-by: Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>
Reported-by: syzbot+5dcb560fe12aa5091c06@...kaller.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
Powered by blists - more mailing lists