aboutsummaryrefslogtreecommitdiff
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-06-21 15:57:50 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-06-21 15:57:50 -0700
commit9738cbe32192919356397f1e24f9b26e1f574fbb (patch)
tree75caa6d21a8b68a36285ee787095fb05b14627fb /mm/mmap.c
parent58229a18994215bbfe0bcd1c99d2e039f30b076b (diff)
parent05dc16d6a175139a5872d08db56ee277ec90df5b (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6: [PARISC] unwinder improvements [PARISC] Fix unwinder on 64-bit kernels [PARISC] Handle wrapping in expand_upwards() [PARISC] stop lcd driver from stripping initial whitespace
Diffstat (limited to 'mm/mmap.c')
-rw-r--r--mm/mmap.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 68b9ad2ef1d..906ed402f7c 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1536,9 +1536,14 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
* vma->vm_start/vm_end cannot change under us because the caller
* is required to hold the mmap_sem in read mode. We need the
* anon_vma lock to serialize against concurrent expand_stacks.
+ * Also guard against wrapping around to address 0.
*/
- address += 4 + PAGE_SIZE - 1;
- address &= PAGE_MASK;
+ if (address < PAGE_ALIGN(address+4))
+ address = PAGE_ALIGN(address+4);
+ else {
+ anon_vma_unlock(vma);
+ return -ENOMEM;
+ }
error = 0;
/* Somebody else might have raced and expanded it already */