diff options
author | James Hogan <james.hogan@imgtec.com> | 2012-05-17 12:42:54 +0100 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2012-05-21 22:20:04 -0400 |
commit | a8908c3517cc93249bb6ec2c693cf80874c7f629 (patch) | |
tree | f0267eed14eee1859deba63980bda7aaea6c774b /libc/sysdeps | |
parent | 8cfb43de636faa401634340d1a18404844f9ba5a (diff) |
mmap()->sys_mmap2: do unsigned shift of offset
Fix the implementation of mmap based on the mmap2 system call, to
construct pgoffset from offset with an unsigned shift rather than a
signed (off_t) shift. The mmap2 test in the testsuite catches this case
by mmap'ing with a large offset (with the sign bit set). The signed
shift repeats the sign bit making the page shift way out of range. This
is already fixed similarly in mmap64().
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libc/sysdeps')
-rw-r--r-- | libc/sysdeps/linux/common/mmap.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libc/sysdeps/linux/common/mmap.c b/libc/sysdeps/linux/common/mmap.c index 89958985e..d53eabb18 100644 --- a/libc/sysdeps/linux/common/mmap.c +++ b/libc/sysdeps/linux/common/mmap.c @@ -63,7 +63,8 @@ __ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offs __set_errno(EINVAL); return MAP_FAILED; } - return __syscall_mmap2(addr, len, prot, flags, fd, offset >> MMAP2_PAGE_SHIFT); + return __syscall_mmap2(addr, len, prot, flags, + fd, ((__u_long) offset >> MMAP2_PAGE_SHIFT)); } libc_hidden_def(mmap) |