]> www.infradead.org Git - users/hch/misc.git/commitdiff
riscv: mmap(): use unsigned offset type in riscv_sys_mmap
authorJessica Liu <liu.xuemei1@zte.com.cn>
Fri, 1 Aug 2025 02:49:48 +0000 (10:49 +0800)
committerPaul Walmsley <pjw@kernel.org>
Thu, 18 Sep 2025 14:19:47 +0000 (08:19 -0600)
The variable type of offset should be consistent with the relevant
interfaces of mmap which described in commit 295f10061af0 ("syscalls:
mmap(): use unsigned offset type consistently"). Otherwise, a user input
with the top bit set would result in a negative page offset rather than a
large one.

Signed-off-by: Jessica Liu <liu.xuemei1@zte.com.cn>
Tested-by: Han Gao <rabenda.cn@gmail.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com>
Link: https://lore.kernel.org/r/20250801104948133AaMr5S6E382PbNNhoJgHA@zte.com.cn
[pjw@kernel.org: hand-applied mangled patch; fixed checkpatch error]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/kernel/sys_riscv.c

index d77afe05578f23d2628ebd56013f84dbfaa37082..795b2e815ac9232c87a521e87970866c0c9e165c 100644 (file)
@@ -10,7 +10,7 @@
 
 static long riscv_sys_mmap(unsigned long addr, unsigned long len,
                           unsigned long prot, unsigned long flags,
-                          unsigned long fd, off_t offset,
+                          unsigned long fd, unsigned long offset,
                           unsigned long page_shift_offset)
 {
        if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))