]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
syscalls: mmap(): use unsigned offset type consistently
authorArnd Bergmann <arnd@arndb.de>
Tue, 4 Jun 2024 12:20:26 +0000 (14:20 +0200)
committerArnd Bergmann <arnd@arndb.de>
Tue, 25 Jun 2024 13:57:38 +0000 (15:57 +0200)
Most architectures that implement the old-style mmap() with byte offset
use 'unsigned long' as the type for that offset, but microblaze and
riscv have the off_t type that is shared with userspace, matching the
prototype in include/asm-generic/syscalls.h.

Make this consistent by using an unsigned argument everywhere. This
changes the behavior slightly, as the argument is shifted to a page
number, and an user input with the top bit set would result in a
negative page offset rather than a large one as we use elsewhere.

For riscv, the 32-bit sys_mmap2() definition actually used a custom
type that is different from the global declaration, but this was
missed due to an incorrect type check.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
arch/csky/kernel/syscall.c
arch/loongarch/kernel/syscall.c
arch/microblaze/kernel/sys_microblaze.c
arch/riscv/kernel/sys_riscv.c
include/asm-generic/syscalls.h

index 3d30e58a45d21c2087b3dcc5d469dc206a9ba2e6..4540a271ee39a7586d2a29b9cc9b7ad607ece3b0 100644 (file)
@@ -20,7 +20,7 @@ SYSCALL_DEFINE6(mmap2,
        unsigned long, prot,
        unsigned long, flags,
        unsigned long, fd,
-       off_t, offset)
+       unsigned long, offset)
 {
        if (unlikely(offset & (~PAGE_MASK >> 12)))
                return -EINVAL;
index b4c5acd7aa3b324d133c0b5bd5e5169bfec5d4f7..8801611143ab3468da11d201be604a1c5ce73f7b 100644 (file)
@@ -22,7 +22,7 @@
 #define __SYSCALL(nr, call)    [nr] = (call),
 
 SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, unsigned long,
-               prot, unsigned long, flags, unsigned long, fd, off_t, offset)
+               prot, unsigned long, flags, unsigned long, fd, unsigned long, offset)
 {
        if (offset & ~PAGE_MASK)
                return -EINVAL;
index ed9f34da1a2a49f4fb86c6cf68f373c2d7e99af7..0850b099f300eacbb711c681f4f41fd2e8eafd13 100644 (file)
@@ -35,7 +35,7 @@
 
 SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
                unsigned long, prot, unsigned long, flags, unsigned long, fd,
-               off_t, pgoff)
+               unsigned long, pgoff)
 {
        if (pgoff & ~PAGE_MASK)
                return -EINVAL;
index 64155323cc923a26b22abdd9357869c894bd0e17..d77afe05578f23d2628ebd56013f84dbfaa37082 100644 (file)
@@ -23,7 +23,7 @@ static long riscv_sys_mmap(unsigned long addr, unsigned long len,
 #ifdef CONFIG_64BIT
 SYSCALL_DEFINE6(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)
 {
        return riscv_sys_mmap(addr, len, prot, flags, fd, offset, 0);
 }
@@ -32,7 +32,7 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
 #if defined(CONFIG_32BIT) || defined(CONFIG_COMPAT)
 SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
        unsigned long, prot, unsigned long, flags,
-       unsigned long, fd, off_t, offset)
+       unsigned long, fd, unsigned long, offset)
 {
        /*
         * Note that the shift for mmap2 is constant (12),
index 933ca6581abace6a4f61bc9f7f720c4f3d526c8e..fabcefe8a80a7db6f30977c4b331ade7c6cb48f7 100644 (file)
@@ -19,7 +19,7 @@ asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
 #ifndef sys_mmap
 asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
                        unsigned long prot, unsigned long flags,
-                       unsigned long fd, off_t pgoff);
+                       unsigned long fd, unsigned long off);
 #endif
 
 #ifndef sys_rt_sigreturn