Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 180448
b: refs/heads/master
c: 803bf5e
h: refs/heads/master
v: v3
  • Loading branch information
Michael Neuling authored and Linus Torvalds committed Feb 11, 2010
1 parent daacef9 commit 498e06d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4cfbafd33f5ae99688ab82525a1d449c1c1b198f
refs/heads/master: 803bf5ec259941936262d10ecc84511b76a20921
21 changes: 19 additions & 2 deletions trunk/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@ int setup_arg_pages(struct linux_binprm *bprm,
struct vm_area_struct *prev = NULL;
unsigned long vm_flags;
unsigned long stack_base;
unsigned long stack_size;
unsigned long stack_expand;
unsigned long rlim_stack;

#ifdef CONFIG_STACK_GROWSUP
/* Limit stack size to 1GB */
Expand Down Expand Up @@ -627,10 +630,24 @@ int setup_arg_pages(struct linux_binprm *bprm,
goto out_unlock;
}

stack_expand = EXTRA_STACK_VM_PAGES * PAGE_SIZE;
stack_size = vma->vm_end - vma->vm_start;
/*
* Align this down to a page boundary as expand_stack
* will align it up.
*/
rlim_stack = rlimit(RLIMIT_STACK) & PAGE_MASK;
rlim_stack = min(rlim_stack, stack_size);
#ifdef CONFIG_STACK_GROWSUP
stack_base = vma->vm_end + EXTRA_STACK_VM_PAGES * PAGE_SIZE;
if (stack_size + stack_expand > rlim_stack)
stack_base = vma->vm_start + rlim_stack;
else
stack_base = vma->vm_end + stack_expand;
#else
stack_base = vma->vm_start - EXTRA_STACK_VM_PAGES * PAGE_SIZE;
if (stack_size + stack_expand > rlim_stack)
stack_base = vma->vm_end - rlim_stack;
else
stack_base = vma->vm_start - stack_expand;
#endif
ret = expand_stack(vma, stack_base);
if (ret)
Expand Down

0 comments on commit 498e06d

Please sign in to comment.