aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2010-09-07 22:35:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-09-10 11:10:26 -0400
commit1b528181b2ffa14721fb28ad1bd539fe1732c583 (patch)
treec6c11dd4fb1845ce1a7d5c048fba40a62d5d94de /fs/exec.c
parentbe6200aac985e0a3db56ec636763a32f3e32e7f1 (diff)
setup_arg_pages: diagnose excessive argument size
The CONFIG_STACK_GROWSDOWN variant of setup_arg_pages() does not check the size of the argument/environment area on the stack. When it is unworkably large, shift_arg_pages() hits its BUG_ON. This is exploitable with a very large RLIMIT_STACK limit, to create a crash pretty easily. Check that the initial stack is not too large to make it possible to map in any executable. We're not checking that the actual executable (or intepreter, for binfmt_elf) will fit. So those mappings might clobber part of the initial stack mapping. But that is just userland lossage that userland made happen, not a kernel problem. Signed-off-by: Roland McGrath <roland@redhat.com> Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 2d9455282744..1b63237fc6dc 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -594,6 +594,11 @@ int setup_arg_pages(struct linux_binprm *bprm,
594#else 594#else
595 stack_top = arch_align_stack(stack_top); 595 stack_top = arch_align_stack(stack_top);
596 stack_top = PAGE_ALIGN(stack_top); 596 stack_top = PAGE_ALIGN(stack_top);
597
598 if (unlikely(stack_top < mmap_min_addr) ||
599 unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
600 return -ENOMEM;
601
597 stack_shift = vma->vm_end - stack_top; 602 stack_shift = vma->vm_end - stack_top;
598 603
599 bprm->p -= stack_shift; 604 bprm->p -= stack_shift;