diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2009-11-24 08:43:52 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-11 06:30:23 -0500 |
commit | 097eed103862f9c6a97f2e415e21d1134017b135 (patch) | |
tree | 32550debe0803051bbce787e6cfa5dc969605615 | |
parent | f106af4e90eadd76cfc0b5325f659619e08fb762 (diff) |
fix the arch checks in MREMAP_FIXED case
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | mm/mremap.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/mm/mremap.c b/mm/mremap.c index 9d0753983dcb..84efffb2d2c4 100644 --- a/mm/mremap.c +++ b/mm/mremap.c | |||
@@ -325,6 +325,7 @@ static unsigned long mremap_to(unsigned long addr, | |||
325 | struct vm_area_struct *vma; | 325 | struct vm_area_struct *vma; |
326 | unsigned long ret = -EINVAL; | 326 | unsigned long ret = -EINVAL; |
327 | unsigned long charged = 0; | 327 | unsigned long charged = 0; |
328 | unsigned long map_flags; | ||
328 | 329 | ||
329 | if (new_addr & ~PAGE_MASK) | 330 | if (new_addr & ~PAGE_MASK) |
330 | goto out; | 331 | goto out; |
@@ -362,9 +363,23 @@ static unsigned long mremap_to(unsigned long addr, | |||
362 | goto out; | 363 | goto out; |
363 | } | 364 | } |
364 | 365 | ||
365 | ret = move_vma(vma, addr, old_len, new_len, new_addr); | 366 | map_flags = MAP_FIXED; |
367 | if (vma->vm_flags & VM_MAYSHARE) | ||
368 | map_flags |= MAP_SHARED; | ||
369 | ret = arch_mmap_check(new_addr, new_len, map_flags); | ||
370 | if (ret) | ||
371 | goto out1; | ||
372 | ret = get_unmapped_area(vma->vm_file, new_addr, new_len, vma->vm_pgoff + | ||
373 | ((addr - vma->vm_start) >> PAGE_SHIFT), | ||
374 | map_flags); | ||
366 | if (ret & ~PAGE_MASK) | 375 | if (ret & ~PAGE_MASK) |
367 | vm_unacct_memory(charged); | 376 | goto out1; |
377 | |||
378 | ret = move_vma(vma, addr, old_len, new_len, new_addr); | ||
379 | if (!(ret & ~PAGE_MASK)) | ||
380 | goto out; | ||
381 | out1: | ||
382 | vm_unacct_memory(charged); | ||
368 | 383 | ||
369 | out: | 384 | out: |
370 | return ret; | 385 | return ret; |