diff options
author | Michal Hocko <mhocko@suse.com> | 2016-05-06 11:15:47 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2016-05-06 14:35:45 +1000 |
commit | 5a006a6df038492bd47558c807acaaba1bb5fa5e (patch) | |
tree | cb582b514eee7e7aa279351b1e9f27c5f71eafb0 | |
parent | 75ab7ced169544cf55cd44ac12b64533e5d1346a (diff) | |
download | linux-5a006a6df038492bd47558c807acaaba1bb5fa5e.tar.gz linux-5a006a6df038492bd47558c807acaaba1bb5fa5e.tar.xz |
mm, elf: handle vm_brk error
load_elf_library doesn't handle vm_brk failure although nothing really
indicates it cannot do that because the function is allowed to fail due to
vm_mmap failures already. This might be not a problem now but later patch
will make vm_brk killable (resp. mmap_sem for write waiting will become
killable) and so the failure will be more probable.
Signed-off-by: Michal Hocko <mhocko@suse.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r-- | fs/binfmt_elf.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 81381cc0dd17..37455ee5aeec 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1176,8 +1176,11 @@ static int load_elf_library(struct file *file) len = ELF_PAGESTART(eppnt->p_filesz + eppnt->p_vaddr + ELF_MIN_ALIGN - 1); bss = eppnt->p_memsz + eppnt->p_vaddr; - if (bss > len) - vm_brk(len, bss - len); + if (bss > len) { + error = vm_brk(len, bss - len); + if (BAD_ADDR(error)) + goto out_free_ph; + } error = 0; out_free_ph: |