mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
8c7b49b3ec
commit
9206de95b1
14
mm/mmap.c
14
mm/mmap.c
|
@ -931,13 +931,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
|
||||||
if (!(flags & MAP_FIXED))
|
if (!(flags & MAP_FIXED))
|
||||||
addr = round_hint_to_min(addr);
|
addr = round_hint_to_min(addr);
|
||||||
|
|
||||||
error = arch_mmap_check(addr, len, flags);
|
|
||||||
if (error)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
/* Careful about overflows.. */
|
/* Careful about overflows.. */
|
||||||
len = PAGE_ALIGN(len);
|
len = PAGE_ALIGN(len);
|
||||||
if (!len || len > TASK_SIZE)
|
if (!len)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* offset overflow? */
|
/* offset overflow? */
|
||||||
|
@ -1437,6 +1433,14 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
|
||||||
unsigned long (*get_area)(struct file *, unsigned long,
|
unsigned long (*get_area)(struct file *, unsigned long,
|
||||||
unsigned long, unsigned long, unsigned long);
|
unsigned long, unsigned long, unsigned long);
|
||||||
|
|
||||||
|
unsigned long error = arch_mmap_check(addr, len, flags);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
/* Careful about overflows.. */
|
||||||
|
if (len > TASK_SIZE)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
get_area = current->mm->get_unmapped_area;
|
get_area = current->mm->get_unmapped_area;
|
||||||
if (file && file->f_op && file->f_op->get_unmapped_area)
|
if (file && file->f_op && file->f_op->get_unmapped_area)
|
||||||
get_area = file->f_op->get_unmapped_area;
|
get_area = file->f_op->get_unmapped_area;
|
||||||
|
|
15
mm/mremap.c
15
mm/mremap.c
|
@ -27,10 +27,6 @@
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
#ifndef arch_mmap_check
|
|
||||||
#define arch_mmap_check(addr, len, flags) (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static pmd_t *get_old_pmd(struct mm_struct *mm, unsigned long addr)
|
static pmd_t *get_old_pmd(struct mm_struct *mm, unsigned long addr)
|
||||||
{
|
{
|
||||||
pgd_t *pgd;
|
pgd_t *pgd;
|
||||||
|
@ -366,9 +362,7 @@ static unsigned long mremap_to(unsigned long addr,
|
||||||
map_flags = MAP_FIXED;
|
map_flags = MAP_FIXED;
|
||||||
if (vma->vm_flags & VM_MAYSHARE)
|
if (vma->vm_flags & VM_MAYSHARE)
|
||||||
map_flags |= MAP_SHARED;
|
map_flags |= MAP_SHARED;
|
||||||
ret = arch_mmap_check(new_addr, new_len, map_flags);
|
|
||||||
if (ret)
|
|
||||||
goto out1;
|
|
||||||
ret = get_unmapped_area(vma->vm_file, new_addr, new_len, vma->vm_pgoff +
|
ret = get_unmapped_area(vma->vm_file, new_addr, new_len, vma->vm_pgoff +
|
||||||
((addr - vma->vm_start) >> PAGE_SHIFT),
|
((addr - vma->vm_start) >> PAGE_SHIFT),
|
||||||
map_flags);
|
map_flags);
|
||||||
|
@ -388,12 +382,9 @@ static unsigned long mremap_to(unsigned long addr,
|
||||||
static int vma_expandable(struct vm_area_struct *vma, unsigned long delta)
|
static int vma_expandable(struct vm_area_struct *vma, unsigned long delta)
|
||||||
{
|
{
|
||||||
unsigned long end = vma->vm_end + delta;
|
unsigned long end = vma->vm_end + delta;
|
||||||
unsigned long max_addr = TASK_SIZE;
|
if (end < vma->vm_end) /* overflow */
|
||||||
if (vma->vm_next)
|
|
||||||
max_addr = vma->vm_next->vm_start;
|
|
||||||
if (max_addr < end || end < vma->vm_end)
|
|
||||||
return 0;
|
return 0;
|
||||||
if (arch_mmap_check(vma->vm_start, end - vma->vm_start, MAP_FIXED))
|
if (vma->vm_next && vma->vm_next->vm_start < end) /* intersection */
|
||||||
return 0;
|
return 0;
|
||||||
if (get_unmapped_area(NULL, vma->vm_start, end - vma->vm_start,
|
if (get_unmapped_area(NULL, vma->vm_start, end - vma->vm_start,
|
||||||
0, MAP_FIXED) & ~PAGE_MASK)
|
0, MAP_FIXED) & ~PAGE_MASK)
|
||||||
|
|
Loading…
Reference in New Issue