diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-03 15:23:11 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-11 06:44:58 -0500 |
commit | 9206de95b1ea68357996ec02be5db0638a0de2c1 (patch) | |
tree | e32b41a06a8465af0e8cfa0660b517930cc2fea5 /mm | |
parent | 8c7b49b3ecd48923eb64ff57e07a1cdb74782970 (diff) |
Take arch_mmap_check() into get_unmapped_area()
Acked-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/mmap.c | 14 | ||||
-rw-r--r-- | mm/mremap.c | 15 |
2 files changed, 12 insertions, 17 deletions
@@ -931,13 +931,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, | |||
931 | if (!(flags & MAP_FIXED)) | 931 | if (!(flags & MAP_FIXED)) |
932 | addr = round_hint_to_min(addr); | 932 | addr = round_hint_to_min(addr); |
933 | 933 | ||
934 | error = arch_mmap_check(addr, len, flags); | ||
935 | if (error) | ||
936 | return error; | ||
937 | |||
938 | /* Careful about overflows.. */ | 934 | /* Careful about overflows.. */ |
939 | len = PAGE_ALIGN(len); | 935 | len = PAGE_ALIGN(len); |
940 | if (!len || len > TASK_SIZE) | 936 | if (!len) |
941 | return -ENOMEM; | 937 | return -ENOMEM; |
942 | 938 | ||
943 | /* offset overflow? */ | 939 | /* offset overflow? */ |
@@ -1437,6 +1433,14 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, | |||
1437 | unsigned long (*get_area)(struct file *, unsigned long, | 1433 | unsigned long (*get_area)(struct file *, unsigned long, |
1438 | unsigned long, unsigned long, unsigned long); | 1434 | unsigned long, unsigned long, unsigned long); |
1439 | 1435 | ||
1436 | unsigned long error = arch_mmap_check(addr, len, flags); | ||
1437 | if (error) | ||
1438 | return error; | ||
1439 | |||
1440 | /* Careful about overflows.. */ | ||
1441 | if (len > TASK_SIZE) | ||
1442 | return -ENOMEM; | ||
1443 | |||
1440 | get_area = current->mm->get_unmapped_area; | 1444 | get_area = current->mm->get_unmapped_area; |
1441 | if (file && file->f_op && file->f_op->get_unmapped_area) | 1445 | if (file && file->f_op && file->f_op->get_unmapped_area) |
1442 | get_area = file->f_op->get_unmapped_area; | 1446 | get_area = file->f_op->get_unmapped_area; |
diff --git a/mm/mremap.c b/mm/mremap.c index bbbbbf507ff3..845190898d59 100644 --- a/mm/mremap.c +++ b/mm/mremap.c | |||
@@ -27,10 +27,6 @@ | |||
27 | 27 | ||
28 | #include "internal.h" | 28 | #include "internal.h" |
29 | 29 | ||
30 | #ifndef arch_mmap_check | ||
31 | #define arch_mmap_check(addr, len, flags) (0) | ||
32 | #endif | ||
33 | |||
34 | static pmd_t *get_old_pmd(struct mm_struct *mm, unsigned long addr) | 30 | static pmd_t *get_old_pmd(struct mm_struct *mm, unsigned long addr) |
35 | { | 31 | { |
36 | pgd_t *pgd; | 32 | pgd_t *pgd; |
@@ -366,9 +362,7 @@ static unsigned long mremap_to(unsigned long addr, | |||
366 | map_flags = MAP_FIXED; | 362 | map_flags = MAP_FIXED; |
367 | if (vma->vm_flags & VM_MAYSHARE) | 363 | if (vma->vm_flags & VM_MAYSHARE) |
368 | map_flags |= MAP_SHARED; | 364 | map_flags |= MAP_SHARED; |
369 | ret = arch_mmap_check(new_addr, new_len, map_flags); | 365 | |
370 | if (ret) | ||
371 | goto out1; | ||
372 | ret = get_unmapped_area(vma->vm_file, new_addr, new_len, vma->vm_pgoff + | 366 | ret = get_unmapped_area(vma->vm_file, new_addr, new_len, vma->vm_pgoff + |
373 | ((addr - vma->vm_start) >> PAGE_SHIFT), | 367 | ((addr - vma->vm_start) >> PAGE_SHIFT), |
374 | map_flags); | 368 | map_flags); |
@@ -388,12 +382,9 @@ out: | |||
388 | static int vma_expandable(struct vm_area_struct *vma, unsigned long delta) | 382 | static int vma_expandable(struct vm_area_struct *vma, unsigned long delta) |
389 | { | 383 | { |
390 | unsigned long end = vma->vm_end + delta; | 384 | unsigned long end = vma->vm_end + delta; |
391 | unsigned long max_addr = TASK_SIZE; | 385 | if (end < vma->vm_end) /* overflow */ |
392 | if (vma->vm_next) | ||
393 | max_addr = vma->vm_next->vm_start; | ||
394 | if (max_addr < end || end < vma->vm_end) | ||
395 | return 0; | 386 | return 0; |
396 | if (arch_mmap_check(vma->vm_start, end - vma->vm_start, MAP_FIXED)) | 387 | if (vma->vm_next && vma->vm_next->vm_start < end) /* intersection */ |
397 | return 0; | 388 | return 0; |
398 | if (get_unmapped_area(NULL, vma->vm_start, end - vma->vm_start, | 389 | if (get_unmapped_area(NULL, vma->vm_start, end - vma->vm_start, |
399 | 0, MAP_FIXED) & ~PAGE_MASK) | 390 | 0, MAP_FIXED) & ~PAGE_MASK) |