mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-11 16:29:05 +00:00
kill do_mmap() completely
just pull into vm_mmap() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
e3fc629d7b
commit
dc982501d9
18
mm/mmap.c
18
mm/mmap.c
@ -1102,17 +1102,6 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
|
|||||||
return mmap_region(file, addr, len, flags, vm_flags, pgoff);
|
return mmap_region(file, addr, len, flags, vm_flags, pgoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long do_mmap(struct file *file, unsigned long addr,
|
|
||||||
unsigned long len, unsigned long prot,
|
|
||||||
unsigned long flag, unsigned long offset)
|
|
||||||
{
|
|
||||||
if (unlikely(offset + PAGE_ALIGN(len) < offset))
|
|
||||||
return -EINVAL;
|
|
||||||
if (unlikely(offset & ~PAGE_MASK))
|
|
||||||
return -EINVAL;
|
|
||||||
return do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long vm_mmap(struct file *file, unsigned long addr,
|
unsigned long vm_mmap(struct file *file, unsigned long addr,
|
||||||
unsigned long len, unsigned long prot,
|
unsigned long len, unsigned long prot,
|
||||||
unsigned long flag, unsigned long offset)
|
unsigned long flag, unsigned long offset)
|
||||||
@ -1120,10 +1109,15 @@ unsigned long vm_mmap(struct file *file, unsigned long addr,
|
|||||||
unsigned long ret;
|
unsigned long ret;
|
||||||
struct mm_struct *mm = current->mm;
|
struct mm_struct *mm = current->mm;
|
||||||
|
|
||||||
|
if (unlikely(offset + PAGE_ALIGN(len) < offset))
|
||||||
|
return -EINVAL;
|
||||||
|
if (unlikely(offset & ~PAGE_MASK))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
ret = security_mmap_file(file, prot, flag);
|
ret = security_mmap_file(file, prot, flag);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
down_write(&mm->mmap_sem);
|
down_write(&mm->mmap_sem);
|
||||||
ret = do_mmap(file, addr, len, prot, flag, offset);
|
ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
|
||||||
up_write(&mm->mmap_sem);
|
up_write(&mm->mmap_sem);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
18
mm/nommu.c
18
mm/nommu.c
@ -1470,17 +1470,6 @@ error_getting_region:
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long do_mmap(struct file *file, unsigned long addr,
|
|
||||||
unsigned long len, unsigned long prot,
|
|
||||||
unsigned long flag, unsigned long offset)
|
|
||||||
{
|
|
||||||
if (unlikely(offset + PAGE_ALIGN(len) < offset))
|
|
||||||
return -EINVAL;
|
|
||||||
if (unlikely(offset & ~PAGE_MASK))
|
|
||||||
return -EINVAL;
|
|
||||||
return do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long vm_mmap(struct file *file, unsigned long addr,
|
unsigned long vm_mmap(struct file *file, unsigned long addr,
|
||||||
unsigned long len, unsigned long prot,
|
unsigned long len, unsigned long prot,
|
||||||
unsigned long flag, unsigned long offset)
|
unsigned long flag, unsigned long offset)
|
||||||
@ -1488,10 +1477,15 @@ unsigned long vm_mmap(struct file *file, unsigned long addr,
|
|||||||
unsigned long ret;
|
unsigned long ret;
|
||||||
struct mm_struct *mm = current->mm;
|
struct mm_struct *mm = current->mm;
|
||||||
|
|
||||||
|
if (unlikely(offset + PAGE_ALIGN(len) < offset))
|
||||||
|
return -EINVAL;
|
||||||
|
if (unlikely(offset & ~PAGE_MASK))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
ret = security_mmap_file(file, prot, flag);
|
ret = security_mmap_file(file, prot, flag);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
down_write(&mm->mmap_sem);
|
down_write(&mm->mmap_sem);
|
||||||
ret = do_mmap(file, addr, len, prot, flag, offset);
|
ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
|
||||||
up_write(&mm->mmap_sem);
|
up_write(&mm->mmap_sem);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user