From 146066a9794b8e39c53337b71a8476b86e79e7d4 Mon Sep 17 00:00:00 2001 From: Chen Minqiang Date: Mon, 16 Oct 2017 08:57:41 +0800 Subject: [PATCH] musl: fix mmap pass wrong offset to kernel on 32bit platform for example off_t x=0x8d9eb000, the x/4096 result is 0xfff8d9eb, but the sys_mmap2() is expecting 0x8d9eb to be pass to this happens on 32bit platform or 64bit platform when x > = 0x80000000 (32bit platform) or x > = 0x8000000000000000 (64bit platform) Signed-off-by: Chen Minqiang --- src/mman/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mman/mmap.c b/src/mman/mmap.c index eff88d82..f225cdbb 100644 --- a/src/mman/mmap.c +++ b/src/mman/mmap.c @@ -26,7 +26,7 @@ void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off) __vm_wait(); } #ifdef SYS_mmap2 - ret = __syscall(SYS_mmap2, start, len, prot, flags, fd, off/UNIT); + ret = __syscall(SYS_mmap2, start, len, prot, flags, fd, (unsigned long)off/UNIT); #else ret = __syscall(SYS_mmap, start, len, prot, flags, fd, off); #endif -- 2.17.1