Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 359198
b: refs/heads/master
c: 0988496
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Feb 27, 2013
1 parent f5446d9 commit 225d570
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d895cb1af15c04c522a25c79cc429076987c089b
refs/heads/master: 09884964335e85e897876d17783c2ad33cf8a2e0
27 changes: 27 additions & 0 deletions trunk/mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2185,9 +2185,28 @@ int expand_downwards(struct vm_area_struct *vma,
return error;
}

/*
* Note how expand_stack() refuses to expand the stack all the way to
* abut the next virtual mapping, *unless* that mapping itself is also
* a stack mapping. We want to leave room for a guard page, after all
* (the guard page itself is not added here, that is done by the
* actual page faulting logic)
*
* This matches the behavior of the guard page logic (see mm/memory.c:
* check_stack_guard_page()), which only allows the guard page to be
* removed under these circumstances.
*/
#ifdef CONFIG_STACK_GROWSUP
int expand_stack(struct vm_area_struct *vma, unsigned long address)
{
struct vm_area_struct *next;

address &= PAGE_MASK;
next = vma->vm_next;
if (next && next->vm_start == address + PAGE_SIZE) {
if (!(next->vm_flags & VM_GROWSUP))
return -ENOMEM;
}
return expand_upwards(vma, address);
}

Expand All @@ -2209,6 +2228,14 @@ find_extend_vma(struct mm_struct *mm, unsigned long addr)
#else
int expand_stack(struct vm_area_struct *vma, unsigned long address)
{
struct vm_area_struct *prev;

address &= PAGE_MASK;
prev = vma->vm_prev;
if (prev && prev->vm_end == address) {
if (!(prev->vm_flags & VM_GROWSDOWN))
return -ENOMEM;
}
return expand_downwards(vma, address);
}

Expand Down

0 comments on commit 225d570

Please sign in to comment.