]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - mm/memory.c
mm: make stack guard page logic use vm_prev pointer
[karo-tx-linux.git] / mm / memory.c
index babb991fb02ba69bdfec04347a14dc2e81d9a836..194dc17560ce3437e5feddd46d032c7ce862ee65 100644 (file)
@@ -2640,11 +2640,18 @@ static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned lo
 {
        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;
+               struct vm_area_struct *prev = vma->vm_prev;
+
+               /*
+                * Is there a mapping abutting this one below?
+                *
+                * That's only ok if it's the same stack mapping
+                * that has gotten split..
+                */
+               if (prev && prev->vm_end == address)
+                       return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
 
-               expand_stack(vma, address);
+               expand_stack(vma, address - PAGE_SIZE);
        }
        return 0;
 }