Skip to content

Commit

Permalink
[MIPS] sys_mmap2 offset argument should always be shifted 12, not PAG…
Browse files Browse the repository at this point in the history
…E_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: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

---
  • Loading branch information
H. Peter Anvin authored and Ralf Baechle committed Mar 21, 2006
1 parent de862b4 commit 947df17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions arch/mips/kernel/linux32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion arch/mips/kernel/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 947df17

Please sign in to comment.