[MIPS] sys_mmap2 offset argument should always be shifted 12, not PAGE_SHIFT.
authorH. Peter Anvin <hpa@zytor.com>
Sat, 25 Feb 2006 05:20:29 +0000 (21:20 -0800)
committerRalf Baechle <ralf@linux-mips.org>
Tue, 21 Mar 2006 13:27:48 +0000 (13:27 +0000)
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: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
---

arch/mips/kernel/linux32.c
arch/mips/kernel/syscall.c

index 1e8d24823d3980e262a4d36b1400cbe65b0a9d51..013bc93688e8a3dd28caf15da957da976998d05b 100644 (file)
@@ -106,6 +106,10 @@ sys32_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
        unsigned long error;
 
        error = -EINVAL;
+       if (pgoff & (~PAGE_MASK >> 12))
+               goto out;
+       pgoff >>= PAGE_SHIFT-12;
+
        if (!(flags & MAP_ANONYMOUS)) {
                error = -EBADF;
                file = fget(fd);
index 55f2bc09529c3ecf16a30ea643d986d9928b3a68..2aeaa2fd4b322a1ebec61d1861eda4aab1ad4e0a 100644 (file)
@@ -162,7 +162,10 @@ asmlinkage unsigned long
 sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
           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);