Commit 947df17c authored by H. Peter Anvin's avatar H. Peter Anvin Committed by Ralf Baechle

[MIPS] sys_mmap2 offset argument should always be shifted 12, not PAGE_SHIFT.

    
This patch adjusts the offset argument passed into sys_mmap2 to be
always shifted 12, even when the native page size isn't 4K.  This is
what all existing userspace libraries expect.
Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>

---
parent de862b48
...@@ -106,6 +106,10 @@ sys32_mmap2(unsigned long addr, unsigned long len, unsigned long prot, ...@@ -106,6 +106,10 @@ sys32_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
unsigned long error; unsigned long error;
error = -EINVAL; error = -EINVAL;
if (pgoff & (~PAGE_MASK >> 12))
goto out;
pgoff >>= PAGE_SHIFT-12;
if (!(flags & MAP_ANONYMOUS)) { if (!(flags & MAP_ANONYMOUS)) {
error = -EBADF; error = -EBADF;
file = fget(fd); file = fget(fd);
......
...@@ -162,7 +162,10 @@ asmlinkage unsigned long ...@@ -162,7 +162,10 @@ asmlinkage unsigned long
sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot, sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
unsigned long flags, unsigned long fd, unsigned long pgoff) unsigned long flags, unsigned long fd, unsigned long pgoff)
{ {
return do_mmap2(addr, len, prot, flags, fd, pgoff); if (pgoff & (~PAGE_MASK >> 12))
return -EINVAL;
return do_mmap2(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT-12));
} }
save_static_function(sys_fork); save_static_function(sys_fork);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment