Skip to content

Commit 295f100

Browse files
committed
syscalls: mmap(): use unsigned offset type consistently
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 <[email protected]>
1 parent 5daf62d commit 295f100

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

arch/csky/kernel/syscall.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SYSCALL_DEFINE6(mmap2,
2020
unsigned long, prot,
2121
unsigned long, flags,
2222
unsigned long, fd,
23-
off_t, offset)
23+
unsigned long, offset)
2424
{
2525
if (unlikely(offset & (~PAGE_MASK >> 12)))
2626
return -EINVAL;

arch/loongarch/kernel/syscall.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define __SYSCALL(nr, call) [nr] = (call),
2323

2424
SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, unsigned long,
25-
prot, unsigned long, flags, unsigned long, fd, off_t, offset)
25+
prot, unsigned long, flags, unsigned long, fd, unsigned long, offset)
2626
{
2727
if (offset & ~PAGE_MASK)
2828
return -EINVAL;

arch/microblaze/kernel/sys_microblaze.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
3737
unsigned long, prot, unsigned long, flags, unsigned long, fd,
38-
off_t, pgoff)
38+
unsigned long, pgoff)
3939
{
4040
if (pgoff & ~PAGE_MASK)
4141
return -EINVAL;

arch/riscv/kernel/sys_riscv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static long riscv_sys_mmap(unsigned long addr, unsigned long len,
2323
#ifdef CONFIG_64BIT
2424
SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
2525
unsigned long, prot, unsigned long, flags,
26-
unsigned long, fd, off_t, offset)
26+
unsigned long, fd, unsigned long, offset)
2727
{
2828
return riscv_sys_mmap(addr, len, prot, flags, fd, offset, 0);
2929
}
@@ -32,7 +32,7 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
3232
#if defined(CONFIG_32BIT) || defined(CONFIG_COMPAT)
3333
SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
3434
unsigned long, prot, unsigned long, flags,
35-
unsigned long, fd, off_t, offset)
35+
unsigned long, fd, unsigned long, offset)
3636
{
3737
/*
3838
* Note that the shift for mmap2 is constant (12),

include/asm-generic/syscalls.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
1919
#ifndef sys_mmap
2020
asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
2121
unsigned long prot, unsigned long flags,
22-
unsigned long fd, off_t pgoff);
22+
unsigned long fd, unsigned long off);
2323
#endif
2424

2525
#ifndef sys_rt_sigreturn

0 commit comments

Comments
 (0)