Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 209180
b: refs/heads/master
c: 320b2b8
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Aug 13, 2010
1 parent e0c182d commit 03628f6
Show file tree
Hide file tree
Showing 2 changed files with 24 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: 2069601b3f0ea38170d4b509b89f3ca0a373bdc1
refs/heads/master: 320b2b8de12698082609ebbc1a17165727f4c893
23 changes: 23 additions & 0 deletions trunk/mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2759,6 +2759,26 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
return ret;
}

/*
* This is like a special single-page "expand_downwards()",
* except we must first make sure that 'address-PAGE_SIZE'
* doesn't hit another vma.
*
* The "find_vma()" will do the right thing even if we wrap
*/
static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
{
address &= PAGE_MASK;
if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
address -= PAGE_SIZE;
if (find_vma(vma->vm_mm, address) != vma)
return -ENOMEM;

expand_stack(vma, address);
}
return 0;
}

/*
* We enter with non-exclusive mmap_sem (to exclude vma changes,
* but allow concurrent faults), and pte mapped but not yet locked.
Expand All @@ -2772,6 +2792,9 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
spinlock_t *ptl;
pte_t entry;

if (check_stack_guard_page(vma, address) < 0)
return VM_FAULT_SIGBUS;

if (!(flags & FAULT_FLAG_WRITE)) {
entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
vma->vm_page_prot));
Expand Down

0 comments on commit 03628f6

Please sign in to comment.