linux system call fixes
Subsystems (18)
cover linux system call fixes
From: Arnd Bergmann <[email protected]>
I'm working on cleanup series for Linux system call handling, trying to unify some of the architecture specific code there among other things.
In the process, I came across a number of bugs that are ABI relevant, so I'm trying to merge these first. I found all of these by inspection, not by running the code, so any extra review would help. I assume some of the issues were already caught by existing LTP tests, while for others we could add a test. Again, I did not check what is already there.
The sync_file_range and fadvise64_64 changes on sh, csky and hexagon are likely to also require changes in the libc implementation.
Once the patches are reviewed, I plan to merge my changes as bugfixes through the asm-generic tree, but architecture maintainers can also pick them up directly to speed up the bugfix.
Arnd
Arnd Bergmann (15):
ftruncate: pass a signed offset
syscalls: fix compat_sys_io_pgetevents_time64 usage
mips: fix compat_sys_lseek syscall
sparc: fix old compat_sys_select()
sparc: fix compat recv/recvfrom syscalls
parisc: use correct compat recv/recvfrom syscalls
parisc: use generic sys_fanotify_mark implementation
powerpc: restore some missing spu syscalls
sh: rework sync_file_range ABI
csky, hexagon: fix broken sys_sync_file_range
hexagon: fix fadvise64_64 calling conventions
s390: remove native mmap2() syscall
syscalls: mmap(): use unsigned offset type consistently
asm-generic: unistd: fix time32 compat syscall handling linux/syscalls.h: add missing __user annotations
arch/arm64/include/asm/unistd32.h | 2 +- arch/csky/include/uapi/asm/unistd.h | 1 + arch/csky/kernel/syscall.c | 2 +- arch/hexagon/include/asm/syscalls.h | 6 + arch/hexagon/include/uapi/asm/unistd.h | 1 + arch/hexagon/kernel/syscalltab.c | 7 + arch/loongarch/kernel/syscall.c | 2 +- arch/microblaze/kernel/sys_microblaze.c | 2 +- arch/mips/kernel/syscalls/syscall_n32.tbl | 2 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 4 +- arch/parisc/Kconfig | 1 + arch/parisc/kernel/sys_parisc32.c | 9 - arch/parisc/kernel/syscalls/syscall.tbl | 6 +- arch/powerpc/kernel/syscalls/syscall.tbl | 6 +- arch/riscv/kernel/sys_riscv.c | 4 +- arch/s390/kernel/syscall.c | 27 --- arch/s390/kernel/syscalls/syscall.tbl | 2 +- arch/sh/kernel/sys_sh32.c | 11 ++ arch/sh/kernel/syscalls/syscall.tbl | 3 +- arch/sparc/kernel/sys32.S | 221 ---------------------- arch/sparc/kernel/syscalls/syscall.tbl | 8 +- arch/x86/entry/syscalls/syscall_32.tbl | 2 +- fs/open.c | 4 +- include/asm-generic/syscalls.h | 2 +- include/linux/compat.h | 2 +- include/linux/syscalls.h | 20 +- include/uapi/asm-generic/unistd.h | 146 +++++++++----- 27 files changed, 160 insertions(+), 343 deletions(-) create mode 100644 arch/hexagon/include/asm/syscalls.h
Signature · 1 line
2.39.2
PATCH 1/15 ftruncate: pass a signed offset
From: Arnd Bergmann <[email protected]>
The old ftruncate() syscall, using the 32-bit off_t misses a sign extension when called in compat mode on 64-bit architectures. As a result, passing a negative length accidentally succeeds in truncating to file size between 2GiB and 4GiB.
Changing the type of the compat syscall to the signed compat_off_t changes the behavior so it instead returns -EINVAL.
The native entry point, the truncate() syscall and the corresponding loff_t based variants are all correct already and do not suffer from this mistake.
--- fs/open.c | 4 ++-- include/linux/compat.h | 2 +- include/linux/syscalls.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/open.c +2 -2
@@ -202,13 +202,13 @@ long do_sys_ftruncate(unsigned int fd, loff_t length, int small)return error; } -SYSCALL_DEFINE2(ftruncate, unsigned int, fd, unsigned long, length) +SYSCALL_DEFINE2(ftruncate, unsigned int, fd, off_t, length) {return do_sys_ftruncate (fd, length,1 ); }#ifdef CONFIG_COMPAT -COMPAT_SYSCALL_DEFINE2(ftruncate, unsigned int, fd, compat_ulong_t, length) +COMPAT_SYSCALL_DEFINE2(ftruncate, unsigned int, fd, compat_off_t, length) {return do_sys_ftruncate (fd, length,1 ); }
include/linux/compat.h +1 -1
@@ -608,7 +608,7 @@ asmlinkage long compat_sys_fstatfs(unsigned int fd,asmlinkage long compat_sys_fstatfs64 (unsigned int fd,compat_size_t sz,struct compat_statfs64 __user *buf);asmlinkage long compat_sys_truncate (const char __user *,compat_off_t ); -asmlinkage long compat_sys_ftruncate (unsigned int ,compat_ulong_t ); +asmlinkage long compat_sys_ftruncate (unsigned int ,compat_off_t );/* No generic prototype for truncate64, ftruncate64, fallocate */ asmlinkage long compat_sys_openat (int dfd,const char __user *filename,int flags,umode_t mode);
include/linux/syscalls.h +1 -1
@@ -418,7 +418,7 @@ asmlinkage long sys_listmount(const struct mnt_id_req __user *req, u64 __user *mnt_ids, size_t nr_mnt_ids, unsigned int flags);asmlinkage long sys_truncate (const char __user *path,long length); -asmlinkage long sys_ftruncate (unsigned int fd,unsigned long length); +asmlinkage long sys_ftruncate (unsigned int fd,off_t length);#if BITS_PER_LONG ==32 asmlinkage long sys_truncate64 (const char __user *path,loff_t length);asmlinkage long sys_ftruncate64 (unsigned int fd,loff_t length);
Signature · 1 line
2.39.2
PATCH 2/15 syscalls: fix compat_sys_io_pgetevents_time64 usage
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
Using sys_io_pgetevents() as the entry point for compat mode tasks works almost correctly, but misses the sign extension for the min_nr and nr arguments.
This was addressed on parisc by switching to compat_sys_io_pgetevents_time64() in commit 6431e92fc827 ("parisc:io_pgetevents_time64() needs compat syscall in 32-bit compat mode"), as well as by using more sophisticated system call wrappers on x86 and s390. However, arm64, mips, powerpc, sparc and riscv still have the same bug.
Changes all of them over to use compat_sys_io_pgetevents_time64() like parisc already does. This was clearly the intention when the function was originally added, but it got hooked up incorrectly in the tables.
--- arch/arm64/include/asm/unistd32.h | 2 +- arch/mips/kernel/syscalls/syscall_n32.tbl | 2 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 2 +- arch/powerpc/kernel/syscalls/syscall.tbl | 2 +- arch/s390/kernel/syscalls/syscall.tbl | 2 +- arch/sparc/kernel/syscalls/syscall.tbl | 2 +- arch/x86/entry/syscalls/syscall_32.tbl | 2 +- include/uapi/asm-generic/unistd.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-)
arch/arm64/include/asm/unistd32.h +1 -1
@@ -840,7 +840,7 @@ __SYSCALL(__NR_pselect6_time64, compat_sys_pselect6_time64)#define __NR_ppoll_time64 414 __SYSCALL(__NR_ppoll_time64, compat_sys_ppoll_time64)#define __NR_io_pgetevents_time64 416 -__SYSCALL(__NR_io_pgetevents_time64, sys_io_pgetevents) +__SYSCALL(__NR_io_pgetevents_time64, compat_sys_io_pgetevents_time64)#define __NR_recvmmsg_time64 417 __SYSCALL(__NR_recvmmsg_time64, compat_sys_recvmmsg_time64)#define __NR_mq_timedsend_time64 418
arch/mips/kernel/syscalls/syscall_n32.tbl +1 -1
@@ -354,7 +354,7 @@ 412 n32 utimensat_time64 sys_utimensat 413 n32 pselect6_time64 compat_sys_pselect6_time64 414 n32 ppoll_time64 compat_sys_ppoll_time64 -416 n32 io_pgetevents_time64 sys_io_pgetevents +416 n32 io_pgetevents_time64 compat_sys_io_pgetevents_time64 417 n32 recvmmsg_time64 compat_sys_recvmmsg_time64 418 n32 mq_timedsend_time64 sys_mq_timedsend 419 n32 mq_timedreceive_time64 sys_mq_timedreceive
arch/mips/kernel/syscalls/syscall_o32.tbl +1 -1
@@ -403,7 +403,7 @@ 412 o32 utimensat_time64 sys_utimensat sys_utimensat 413 o32 pselect6_time64 sys_pselect6 compat_sys_pselect6_time64 414 o32 ppoll_time64 sys_ppoll compat_sys_ppoll_time64 -416 o32 io_pgetevents_time64 sys_io_pgetevents sys_io_pgetevents +416 o32 io_pgetevents_time64 sys_io_pgetevents compat_sys_io_pgetevents_time64 417 o32 recvmmsg_time64 sys_recvmmsg compat_sys_recvmmsg_time64 418 o32 mq_timedsend_time64 sys_mq_timedsend sys_mq_timedsend 419 o32 mq_timedreceive_time64 sys_mq_timedreceive sys_mq_timedreceive
arch/powerpc/kernel/syscalls/syscall.tbl +1 -1
@@ -502,7 +502,7 @@ 412 32 utimensat_time64 sys_utimensat sys_utimensat 413 32 pselect6_time64 sys_pselect6 compat_sys_pselect6_time64 414 32 ppoll_time64 sys_ppoll compat_sys_ppoll_time64 -416 32 io_pgetevents_time64 sys_io_pgetevents sys_io_pgetevents +416 32 io_pgetevents_time64 sys_io_pgetevents compat_sys_io_pgetevents_time64 417 32 recvmmsg_time64 sys_recvmmsg compat_sys_recvmmsg_time64 418 32 mq_timedsend_time64 sys_mq_timedsend sys_mq_timedsend 419 32 mq_timedreceive_time64 sys_mq_timedreceive sys_mq_timedreceive
arch/s390/kernel/syscalls/syscall.tbl +1 -1
@@ -418,7 +418,7 @@ 412 32 utimensat_time64 - sys_utimensat 413 32 pselect6_time64 - compat_sys_pselect6_time64 414 32 ppoll_time64 - compat_sys_ppoll_time64 -416 32 io_pgetevents_time64 - sys_io_pgetevents +416 32 io_pgetevents_time64 - compat_sys_io_pgetevents_time64 417 32 recvmmsg_time64 - compat_sys_recvmmsg_time64 418 32 mq_timedsend_time64 - sys_mq_timedsend 419 32 mq_timedreceive_time64 - sys_mq_timedreceive
arch/sparc/kernel/syscalls/syscall.tbl +1 -1
@@ -461,7 +461,7 @@ 412 32 utimensat_time64 sys_utimensat sys_utimensat 413 32 pselect6_time64 sys_pselect6 compat_sys_pselect6_time64 414 32 ppoll_time64 sys_ppoll compat_sys_ppoll_time64 -416 32 io_pgetevents_time64 sys_io_pgetevents sys_io_pgetevents +416 32 io_pgetevents_time64 sys_io_pgetevents compat_sys_io_pgetevents_time64 417 32 recvmmsg_time64 sys_recvmmsg compat_sys_recvmmsg_time64 418 32 mq_timedsend_time64 sys_mq_timedsend sys_mq_timedsend 419 32 mq_timedreceive_time64 sys_mq_timedreceive sys_mq_timedreceive
arch/x86/entry/syscalls/syscall_32.tbl +1 -1
@@ -420,7 +420,7 @@ 412 i386 utimensat_time64 sys_utimensat 413 i386 pselect6_time64 sys_pselect6 compat_sys_pselect6_time64 414 i386 ppoll_time64 sys_ppoll compat_sys_ppoll_time64 -416 i386 io_pgetevents_time64 sys_io_pgetevents +416 i386 io_pgetevents_time64 sys_io_pgetevents compat_sys_io_pgetevents_time64 417 i386 recvmmsg_time64 sys_recvmmsg compat_sys_recvmmsg_time64 418 i386 mq_timedsend_time64 sys_mq_timedsend 419 i386 mq_timedreceive_time64 sys_mq_timedreceive
include/uapi/asm-generic/unistd.h +1 -1
@@ -737,7 +737,7 @@ __SC_COMP(__NR_pselect6_time64, sys_pselect6, compat_sys_pselect6_time64)#define __NR_ppoll_time64 414 __SC_COMP(__NR_ppoll_time64, sys_ppoll, compat_sys_ppoll_time64)#define __NR_io_pgetevents_time64 416 -__SYSCALL(__NR_io_pgetevents_time64, sys_io_pgetevents) +__SYSCALL(__NR_io_pgetevents_time64, sys_io_pgetevents, compat_sys_io_pgetevents_time64)#define __NR_recvmmsg_time64 417 __SC_COMP(__NR_recvmmsg_time64, sys_recvmmsg, compat_sys_recvmmsg_time64)#define __NR_mq_timedsend_time64 418
Signature · 1 line
2.39.2
PATCH 3/15 mips: fix compat_sys_lseek syscall
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
This is almost compatible, but passing a negative offset should result in a EINVAL error, but on mips o32 compat mode would seek to a large 32-bit byte offset.
Use compat_sys_lseek() to correctly sign-extend the argument.
--- arch/mips/kernel/syscalls/syscall_o32.tbl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/syscalls/syscall_o32.tbl +1 -1
@@ -27,7 +27,7 @@ 17 o32 break sys_ni_syscall # 18 was sys_stat 18 o32 unused18 sys_ni_syscall -19 o32 lseek sys_lseek +19 o32 lseek sys_lseek compat_sys_lseek 20 o32 getpid sys_getpid 21 o32 mount sys_mount 22 o32 umount sys_oldumount
Signature · 1 line
2.39.2
PATCH 4/15 sparc: fix old compat_sys_select()
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
sparc has two identical select syscalls at numbers 93 and 230, respectively. During the conversion to the modern syscall.tbl format, the older one of the two broke in compat mode, and now refers to the native 64-bit syscall.
Restore the correct behavior. This has very little effect, as glibc has been using the newer number anyway.
--- arch/sparc/kernel/syscalls/syscall.tbl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/syscalls/syscall.tbl +1 -1
@@ -117,7 +117,7 @@ 90 common dup2 sys_dup2 91 32 setfsuid32 sys_setfsuid 92 common fcntl sys_fcntl compat_sys_fcntl -93 common select sys_select +93 common select sys_select compat_sys_select 94 32 setfsgid32 sys_setfsgid 95 common fsync sys_fsync 96 common setpriority sys_setpriority
Signature · 1 line
2.39.2
PATCH 5/15 sparc: fix compat recv/recvfrom syscalls
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
sparc has the wrong compat version of recv() and recvfrom() for both the direct syscalls and socketcall().
The direct syscalls just need to use the compat version. For socketcall, the same thing could be done, but it seems better to completely remove the custom assembler code for it and just use the same implementation that everyone else has.
--- arch/sparc/kernel/sys32.S | 221 ------------------------- arch/sparc/kernel/syscalls/syscall.tbl | 4 +- 2 files changed, 2 insertions(+), 223 deletions(-)
arch/sparc/kernel/sys32.S +0 -221
@@ -18,224 +18,3 @@ sys32_mmap2: sethi %hi(sys_mmap), %g1 jmpl %g1 + %lo(sys_mmap), %g0 sllx %o5, 12, %o5 - - .align 32 - .globl sys32_socketcall -sys32_socketcall: /* %o0=call, %o1=args */ - cmp %o0, 1 - bl,pn %xcc, do_einval - cmp %o0, 18 - bg,pn %xcc, do_einval - sub %o0, 1, %o0 - sllx %o0, 5, %o0 - sethi %hi(__socketcall_table_begin), %g2 - or %g2, %lo(__socketcall_table_begin), %g2 - jmpl %g2 + %o0, %g0 - nop -do_einval: - retl - mov -EINVAL, %o0 - - .align 32 -__socketcall_table_begin: - - /* Each entry is exactly 32 bytes. */ -do_sys_socket: /* sys_socket(int, int, int) */ -1: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_socket), %g1 -2: ldswa [%o1 + 0x8] %asi, %o2 - jmpl %g1 + %lo(sys_socket), %g0 -3: ldswa [%o1 + 0x4] %asi, %o1 - nop - nop - nop -do_sys_bind: /* sys_bind(int fd, struct sockaddr *, int) */ -4: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_bind), %g1 -5: ldswa [%o1 + 0x8] %asi, %o2 - jmpl %g1 + %lo(sys_bind), %g0 -6: lduwa [%o1 + 0x4] %asi, %o1 - nop - nop - nop -do_sys_connect: /* sys_connect(int, struct sockaddr *, int) */ -7: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_connect), %g1 -8: ldswa [%o1 + 0x8] %asi, %o2 - jmpl %g1 + %lo(sys_connect), %g0 -9: lduwa [%o1 + 0x4] %asi, %o1 - nop - nop - nop -do_sys_listen: /* sys_listen(int, int) */ -10: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_listen), %g1 - jmpl %g1 + %lo(sys_listen), %g0 -11: ldswa [%o1 + 0x4] %asi, %o1 - nop - nop - nop - nop -do_sys_accept: /* sys_accept(int, struct sockaddr *, int *) */ -12: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_accept), %g1 -13: lduwa [%o1 + 0x8] %asi, %o2 - jmpl %g1 + %lo(sys_accept), %g0 -14: lduwa [%o1 + 0x4] %asi, %o1 - nop - nop - nop -do_sys_getsockname: /* sys_getsockname(int, struct sockaddr *, int *) */ -15: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_getsockname), %g1 -16: lduwa [%o1 + 0x8] %asi, %o2 - jmpl %g1 + %lo(sys_getsockname), %g0 -17: lduwa [%o1 + 0x4] %asi, %o1 - nop - nop - nop -do_sys_getpeername: /* sys_getpeername(int, struct sockaddr *, int *) */ -18: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_getpeername), %g1 -19: lduwa [%o1 + 0x8] %asi, %o2 - jmpl %g1 + %lo(sys_getpeername), %g0 -20: lduwa [%o1 + 0x4] %asi, %o1 - nop - nop - nop -do_sys_socketpair: /* sys_socketpair(int, int, int, int *) */ -21: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_socketpair), %g1 -22: ldswa [%o1 + 0x8] %asi, %o2 -23: lduwa [%o1 + 0xc] %asi, %o3 - jmpl %g1 + %lo(sys_socketpair), %g0 -24: ldswa [%o1 + 0x4] %asi, %o1 - nop - nop -do_sys_send: /* sys_send(int, void *, size_t, unsigned int) */ -25: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_send), %g1 -26: lduwa [%o1 + 0x8] %asi, %o2 -27: lduwa [%o1 + 0xc] %asi, %o3 - jmpl %g1 + %lo(sys_send), %g0 -28: lduwa [%o1 + 0x4] %asi, %o1 - nop - nop -do_sys_recv: /* sys_recv(int, void *, size_t, unsigned int) */ -29: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_recv), %g1 -30: lduwa [%o1 + 0x8] %asi, %o2 -31: lduwa [%o1 + 0xc] %asi, %o3 - jmpl %g1 + %lo(sys_recv), %g0 -32: lduwa [%o1 + 0x4] %asi, %o1 - nop - nop -do_sys_sendto: /* sys_sendto(int, u32, compat_size_t, unsigned int, u32, int) */ -33: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_sendto), %g1 -34: lduwa [%o1 + 0x8] %asi, %o2 -35: lduwa [%o1 + 0xc] %asi, %o3 -36: lduwa [%o1 + 0x10] %asi, %o4 -37: ldswa [%o1 + 0x14] %asi, %o5 - jmpl %g1 + %lo(sys_sendto), %g0 -38: lduwa [%o1 + 0x4] %asi, %o1 -do_sys_recvfrom: /* sys_recvfrom(int, u32, compat_size_t, unsigned int, u32, u32) */ -39: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_recvfrom), %g1 -40: lduwa [%o1 + 0x8] %asi, %o2 -41: lduwa [%o1 + 0xc] %asi, %o3 -42: lduwa [%o1 + 0x10] %asi, %o4 -43: lduwa [%o1 + 0x14] %asi, %o5 - jmpl %g1 + %lo(sys_recvfrom), %g0 -44: lduwa [%o1 + 0x4] %asi, %o1 -do_sys_shutdown: /* sys_shutdown(int, int) */ -45: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_shutdown), %g1 - jmpl %g1 + %lo(sys_shutdown), %g0 -46: ldswa [%o1 + 0x4] %asi, %o1 - nop - nop - nop - nop -do_sys_setsockopt: /* sys_setsockopt(int, int, int, char *, int) */ -47: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_setsockopt), %g1 -48: ldswa [%o1 + 0x8] %asi, %o2 -49: lduwa [%o1 + 0xc] %asi, %o3 -50: ldswa [%o1 + 0x10] %asi, %o4 - jmpl %g1 + %lo(sys_setsockopt), %g0 -51: ldswa [%o1 + 0x4] %asi, %o1 - nop -do_sys_getsockopt: /* sys_getsockopt(int, int, int, u32, u32) */ -52: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_getsockopt), %g1 -53: ldswa [%o1 + 0x8] %asi, %o2 -54: lduwa [%o1 + 0xc] %asi, %o3 -55: lduwa [%o1 + 0x10] %asi, %o4 - jmpl %g1 + %lo(sys_getsockopt), %g0 -56: ldswa [%o1 + 0x4] %asi, %o1 - nop -do_sys_sendmsg: /* compat_sys_sendmsg(int, struct compat_msghdr *, unsigned int) */ -57: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(compat_sys_sendmsg), %g1 -58: lduwa [%o1 + 0x8] %asi, %o2 - jmpl %g1 + %lo(compat_sys_sendmsg), %g0 -59: lduwa [%o1 + 0x4] %asi, %o1 - nop - nop - nop -do_sys_recvmsg: /* compat_sys_recvmsg(int, struct compat_msghdr *, unsigned int) */ -60: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(compat_sys_recvmsg), %g1 -61: lduwa [%o1 + 0x8] %asi, %o2 - jmpl %g1 + %lo(compat_sys_recvmsg), %g0 -62: lduwa [%o1 + 0x4] %asi, %o1 - nop - nop - nop -do_sys_accept4: /* sys_accept4(int, struct sockaddr *, int *, int) */ -63: ldswa [%o1 + 0x0] %asi, %o0 - sethi %hi(sys_accept4), %g1 -64: lduwa [%o1 + 0x8] %asi, %o2 -65: ldswa [%o1 + 0xc] %asi, %o3 - jmpl %g1 + %lo(sys_accept4), %g0 -66: lduwa [%o1 + 0x4] %asi, %o1 - nop - nop - - .section __ex_table,"a" - .align 4 - .word 1b, __retl_efault, 2b, __retl_efault - .word 3b, __retl_efault, 4b, __retl_efault - .word 5b, __retl_efault, 6b, __retl_efault - .word 7b, __retl_efault, 8b, __retl_efault - .word 9b, __retl_efault, 10b, __retl_efault - .word 11b, __retl_efault, 12b, __retl_efault - .word 13b, __retl_efault, 14b, __retl_efault - .word 15b, __retl_efault, 16b, __retl_efault - .word 17b, __retl_efault, 18b, __retl_efault - .word 19b, __retl_efault, 20b, __retl_efault - .word 21b, __retl_efault, 22b, __retl_efault - .word 23b, __retl_efault, 24b, __retl_efault - .word 25b, __retl_efault, 26b, __retl_efault - .word 27b, __retl_efault, 28b, __retl_efault - .word 29b, __retl_efault, 30b, __retl_efault - .word 31b, __retl_efault, 32b, __retl_efault - .word 33b, __retl_efault, 34b, __retl_efault - .word 35b, __retl_efault, 36b, __retl_efault - .word 37b, __retl_efault, 38b, __retl_efault - .word 39b, __retl_efault, 40b, __retl_efault - .word 41b, __retl_efault, 42b, __retl_efault - .word 43b, __retl_efault, 44b, __retl_efault - .word 45b, __retl_efault, 46b, __retl_efault - .word 47b, __retl_efault, 48b, __retl_efault - .word 49b, __retl_efault, 50b, __retl_efault - .word 51b, __retl_efault, 52b, __retl_efault - .word 53b, __retl_efault, 54b, __retl_efault - .word 55b, __retl_efault, 56b, __retl_efault - .word 57b, __retl_efault, 58b, __retl_efault - .word 59b, __retl_efault, 60b, __retl_efault - .word 61b, __retl_efault, 62b, __retl_efault - .word 63b, __retl_efault, 64b, __retl_efault - .word 65b, __retl_efault, 66b, __retl_efault - .previous
arch/sparc/kernel/syscalls/syscall.tbl +2 -2
@@ -155,7 +155,7 @@ 123 32 fchown sys_fchown16 123 64 fchown sys_fchown 124 common fchmod sys_fchmod -125 common recvfrom sys_recvfrom +125 common recvfrom sys_recvfrom compat_sys_recvfrom 126 32 setreuid sys_setreuid16 126 64 setreuid sys_setreuid 127 32 setregid sys_setregid16
@@ -247,7 +247,7 @@ 204 32 readdir sys_old_readdir compat_sys_old_readdir 204 64 readdir sys_nis_syscall 205 common readahead sys_readahead compat_sys_readahead -206 common socketcall sys_socketcall sys32_socketcall +206 common socketcall sys_socketcall compat_sys_socketcall 207 common syslog sys_syslog 208 common lookup_dcookie sys_ni_syscall 209 common fadvise64 sys_fadvise64 compat_sys_fadvise64
Signature · 1 line
2.39.2
PATCH 6/15 parisc: use correct compat recv/recvfrom syscalls
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
Johannes missed parisc back when he introduced the compat version of these syscalls, so receiving cmsg messages that require a compat conversion is still broken.
Use the correct calls like the other architectures do.
--- arch/parisc/kernel/syscalls/syscall.tbl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/parisc/kernel/syscalls/syscall.tbl +2 -2
@@ -108,7 +108,7 @@ 95 common fchown sys_fchown 96 common getpriority sys_getpriority 97 common setpriority sys_setpriority -98 common recv sys_recv +98 common recv sys_recv compat_sys_recv 99 common statfs sys_statfs compat_sys_statfs 100 common fstatfs sys_fstatfs compat_sys_fstatfs 101 common stat64 sys_stat64
@@ -135,7 +135,7 @@ 120 common clone sys_clone_wrapper 121 common setdomainname sys_setdomainname 122 common sendfile sys_sendfile compat_sys_sendfile -123 common recvfrom sys_recvfrom +123 common recvfrom sys_recvfrom compat_sys_recvfrom 124 32 adjtimex sys_adjtimex_time32 124 64 adjtimex sys_adjtimex 125 common mprotect sys_mprotect
Signature · 1 line
2.39.2
PATCH 7/15 parisc: use generic sys_fanotify_mark implementation
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The sys_fanotify_mark() syscall on parisc uses the reverse word order for the two halves of the 64-bit argument compared to all syscalls on all 32-bit architectures. As far as I can tell, the problem is that the function arguments on parisc are sorted backwards (26, 25, 24, 23, ...) compared to everyone else, so the calling conventions of using an even/odd register pair in native word order result in the lower word coming first in function arguments, matching the expected behavior on little-endian architectures. The system call conventions however ended up matching what the other 32-bit architectures do.
A glibc cleanup in 2020 changed the userspace behavior in a way that handles all architectures consistently, but this inadvertently broke parisc32 by changing to the same method as everyone else.
The change made it into glibc-2.35 and subsequently into debian 12 (bookworm), which is the latest stable release. This means we need to choose between reverting the glibc change or changing the kernel to match it again, but either hange will leave some systems broken.
Pick the option that is more likely to help current and future users and change the kernel to match current glibc. This also means the behavior is now consistent across architectures, but it breaks running new kernels with old glibc builds before 2.35.
---
I found this through code inspection, please double-check to make sure I got the bug and the fix right.
The alternative is to fix this by reverting glibc back to the unusual behavior.
--- arch/parisc/Kconfig | 1 + arch/parisc/kernel/sys_parisc32.c | 9 --------- arch/parisc/kernel/syscalls/syscall.tbl | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-)
arch/parisc/Kconfig +1 -0
@@ -16,6 +16,7 @@ config PARISC select ARCH_HAS_UBSAN select ARCH_HAS_PTE_SPECIAL select ARCH_NO_SG_CHAIN + select ARCH_SPLIT_ARG64 if !64BIT select ARCH_SUPPORTS_HUGETLBFS if PA20 select ARCH_SUPPORTS_MEMORY_FAILURE select ARCH_STACKWALK
arch/parisc/kernel/sys_parisc32.c +0 -9
@@ -23,12 +23,3 @@ asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23, current->comm, current->pid, r20);return -ENOSYS ; } - -asmlinkage long sys32_fanotify_mark (compat_int_t fanotify_fd,compat_uint_t flags, -compat_uint_t mask0,compat_uint_t mask1,compat_int_t dfd, -const char __user * pathname) -{ -return sys_fanotify_mark (fanotify_fd, flags, - ((__u64 )mask1 <<32 ) | mask0, - dfd, pathname); -}
arch/parisc/kernel/syscalls/syscall.tbl +1 -1
@@ -364,7 +364,7 @@ 320 common accept4 sys_accept4 321 common prlimit64 sys_prlimit64 322 common fanotify_init sys_fanotify_init -323 common fanotify_mark sys_fanotify_mark sys32_fanotify_mark +323 common fanotify_mark sys_fanotify_mark compat_sys_fanotify_mark 324 32 clock_adjtime sys_clock_adjtime32 324 64 clock_adjtime sys_clock_adjtime 325 common name_to_handle_at sys_name_to_handle_at
Signature · 1 line
2.39.2
PATCH 8/15 powerpc: restore some missing spu syscalls
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
A couple of system calls were inadventently removed from the table during a bugfix for 32-bit powerpc entry. Restore the original behavior.
--- arch/powerpc/kernel/syscalls/syscall.tbl | 4 ++++ 1 file changed, 4 insertions(+)
arch/powerpc/kernel/syscalls/syscall.tbl +4 -0
@@ -230,8 +230,10 @@ 178 nospu rt_sigsuspend sys_rt_sigsuspend compat_sys_rt_sigsuspend 179 32 pread64 sys_ppc_pread64 compat_sys_ppc_pread64 179 64 pread64 sys_pread64 +179 spu pread64 sys_pread64 180 32 pwrite64 sys_ppc_pwrite64 compat_sys_ppc_pwrite64 180 64 pwrite64 sys_pwrite64 +180 spu pwrite64 sys_pwrite64 181 common chown sys_chown 182 common getcwd sys_getcwd 183 common capget sys_capget
@@ -246,6 +248,7 @@ 190 common ugetrlimit sys_getrlimit compat_sys_getrlimit 191 32 readahead sys_ppc_readahead compat_sys_ppc_readahead 191 64 readahead sys_readahead +191 spu readahead sys_readahead 192 32 mmap2 sys_mmap2 compat_sys_mmap2 193 32 truncate64 sys_ppc_truncate64 compat_sys_ppc_truncate64 194 32 ftruncate64 sys_ppc_ftruncate64 compat_sys_ppc_ftruncate64
@@ -293,6 +296,7 @@ 232 nospu set_tid_address sys_set_tid_address 233 32 fadvise64 sys_ppc32_fadvise64 compat_sys_ppc32_fadvise64 233 64 fadvise64 sys_fadvise64 +233 spu fadvise64 sys_fadvise64 234 nospu exit_group sys_exit_group 235 nospu lookup_dcookie sys_ni_syscall 236 common epoll_create sys_epoll_create
Signature · 1 line
2.39.2
PATCH 9/15 sh: rework sync_file_range ABI
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The unusual function calling conventions on superh ended up causing sync_file_range to have the wrong argument order, with the 'flags' argument getting sorted before 'nbytes' by the compiler.
In userspace, I found that musl, glibc, uclibc and strace all expect the normal calling conventions with 'nbytes' last, so changing the kernel to match them should make all of those work.
In order to be able to also fix libc implementations to work with existing kernels, they need to be able to tell which ABI is used. An easy way to do this is to add yet another system call using the sync_file_range2 ABI that works the same on all architectures.
Old user binaries can now work on new kernels, and new binaries can try the new sync_file_range2() to work with new kernels or fall back to the old sync_file_range() version if that doesn't exist.
--- arch/sh/kernel/sys_sh32.c | 11 +++++++++++ arch/sh/kernel/syscalls/syscall.tbl | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-)
arch/sh/kernel/sys_sh32.c +11 -0
@@ -59,3 +59,14 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, (u64)len0 << 32 | len1, advice);#endif } + +/* +* swap the arguments the way that libc wants it instead of +* moving flags ahead of the 64-bit nbytes argument +*/ +SYSCALL_DEFINE6 (sh_sync_file_range6, int, fd,SC_ARG64 (offset), + SC_ARG64(nbytes), unsigned int, flags) +{ +return ksys_sync_file_range (fd,SC_VAL64 (loff_t, offset), +SC_VAL64 (loff_t, nbytes), flags); +}
arch/sh/kernel/syscalls/syscall.tbl +2 -1
@@ -321,7 +321,7 @@ 311 common set_robust_list sys_set_robust_list 312 common get_robust_list sys_get_robust_list 313 common splice sys_splice -314 common sync_file_range sys_sync_file_range +314 common sync_file_range sys_sh_sync_file_range6 315 common tee sys_tee 316 common vmsplice sys_vmsplice 317 common move_pages sys_move_pages
@@ -395,6 +395,7 @@ 385 common pkey_alloc sys_pkey_alloc 386 common pkey_free sys_pkey_free 387 common rseq sys_rseq +388 common sync_file_range2 sys_sync_file_range2 # room for arch specific syscalls 393 common semget sys_semget 394 common semctl sys_semctl
Signature · 1 line
2.39.2
PATCH 10/15 csky, hexagon: fix broken sys_sync_file_range
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
Both of these architectures require u64 function arguments to be passed in even/odd pairs of registers or stack slots, which in case of sync_file_range would result in a seven-argument system call that is not currently possible. The system call is therefore incompatible with all existing binaries.
While it would be possible to implement support for seven arguments like on mips, it seems better to use a six-argument version, either with the normal argument order but misaligned as on most architectures or with the reordered sync_file_range2() calling conventions as on arm and powerpc.
--- arch/csky/include/uapi/asm/unistd.h | 1 + arch/hexagon/include/uapi/asm/unistd.h | 1 + 2 files changed, 2 insertions(+)
arch/csky/include/uapi/asm/unistd.h +1 -0
@@ -6,6 +6,7 @@#define __ARCH_WANT_SYS_CLONE3#define __ARCH_WANT_SET_GET_RLIMIT#define __ARCH_WANT_TIME32_SYSCALLS +#define __ARCH_WANT_SYNC_FILE_RANGE2#include <asm-generic/unistd.h> #define __NR_set_thread_area (__NR_arch_specific_syscall + 0)
arch/hexagon/include/uapi/asm/unistd.h +1 -0
@@ -36,5 +36,6 @@#define __ARCH_WANT_SYS_VFORK#define __ARCH_WANT_SYS_FORK#define __ARCH_WANT_TIME32_SYSCALLS +#define __ARCH_WANT_SYNC_FILE_RANGE2#include <asm-generic/unistd.h>
Signature · 1 line
2.39.2
PATCH 11/15 hexagon: fix fadvise64_64 calling conventions
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
fadvise64_64() has two 64-bit arguments at the wrong alignment for hexagon, which turns them into a 7-argument syscall that is not supported by Linux.
The downstream musl port for hexagon actually asks for a 6-argument version the same way we do it on arm, csky, powerpc, so make the kernel do it the same way to avoid having to change both.
--- arch/hexagon/include/asm/syscalls.h | 6 ++++++ arch/hexagon/kernel/syscalltab.c | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 arch/hexagon/include/asm/syscalls.h
arch/hexagon/include/asm/syscalls.h new file +6 -0
@@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#include <asm-generic/syscalls.h> + +asmlinkage long sys_hexagon_fadvise64_64 (int fd,int advice, +u32 a2,u32 a3,u32 a4,u32 a5);
arch/hexagon/kernel/syscalltab.c +7 -0
@@ -14,6 +14,13 @@#undef __SYSCALL#define __SYSCALL (nr, call) [nr] = (call), +SYSCALL_DEFINE6 (hexagon_fadvise64_64, int, fd, int, advice, + SC_ARG64(offset), SC_ARG64(len)) +{ +return ksys_fadvise64_64 (fd,SC_VAL64 (loff_t, offset),SC_VAL64 (loff_t, len), advice); +} +#define sys_fadvise64_64 sys_hexagon_fadvise64_64 + void *sys_call_table[__NR_syscalls] = {#include <asm/unistd.h> };
Signature · 1 line
2.39.2
PATCH 12/15 s390: remove native mmap2() syscall
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
The mmap2() syscall has never been used on 64-bit s390x and should have been removed as part of 5a79859ae0f3 ("s390: remove 31 bit support").
Remove it now.
--- arch/s390/kernel/syscall.c | 27 --------------------------- 1 file changed, 27 deletions(-)
arch/s390/kernel/syscall.c +0 -27
@@ -38,33 +38,6 @@#include "entry.h" -/* -* Perform the mmap() system call. Linux for S/390 isn't able to handle more -* than 5 system call parameters, so this system call uses a memory block -* for parameter passing. -*/ - -struct s390_mmap_arg_struct { -unsigned long addr; -unsigned long len; -unsigned long prot; -unsigned long flags; -unsigned long fd; -unsigned long offset; -}; - -SYSCALL_DEFINE1(mmap2, struct s390_mmap_arg_struct __user *, arg) -{ -struct s390_mmap_arg_struct a; -int error = -EFAULT ; - -if (copy_from_user (&a, arg,sizeof (a))) - goto out; - error =ksys_mmap_pgoff (a.addr, a.len, a.prot, a.flags, a.fd, a.offset); -out: -return error; -} -#ifdef CONFIG_SYSVIPC /* * sys_ipc() is the de-multiplexer for the SysV IPC calls.
Signature · 1 line
2.39.2
PATCH 13/15 syscalls: mmap(): use unsigned offset type consistently
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
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.
--- arch/csky/kernel/syscall.c | 2 +- arch/loongarch/kernel/syscall.c | 2 +- arch/microblaze/kernel/sys_microblaze.c | 2 +- arch/riscv/kernel/sys_riscv.c | 4 ++-- include/asm-generic/syscalls.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-)
arch/csky/kernel/syscall.c +1 -1
@@ -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;
arch/loongarch/kernel/syscall.c +1 -1
@@ -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 ;
arch/microblaze/kernel/sys_microblaze.c +1 -1
@@ -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 ;
arch/riscv/kernel/sys_riscv.c +2 -2
@@ -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),
include/asm-generic/syscalls.h +1 -1
@@ -19,7 +19,7 @@ asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,#ifndef sys_mmapasmlinkage 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
Signature · 1 line
2.39.2
PATCH 14/15 asm-generic: unistd: fix time32 compat syscall handling
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
arch/riscv/ appears to have accidentally enabled the compat time32 syscalls in 64-bit kernels even though the native 32-bit ABI does not expose those.
Address this by adding another level of indirection, checking for both the target ABI (32 or 64) and the __ARCH_WANT_TIME32_SYSCALLS macro.
The macro arguments are meant to follow the syscall.tbl format, the idea here is that by the end of the series, all other syscalls are changed to the same format to make it possible to move all architectures over to generating the system call table consistently.
Only this patch needs to be backported though.
--- include/uapi/asm-generic/unistd.h | 146 +++++++++++++++++++----------- 1 file changed, 94 insertions(+), 52 deletions(-)
include/uapi/asm-generic/unistd.h +94 -52
@@ -16,10 +16,32 @@#define __SYSCALL (x, y)#endif +#ifndef __SC +#define __SC (_cond, _nr, _sys) __SYSCALL_ ## _cond (_nr, _sys) +#endif + +#ifndef __SCC +#ifdef __SYSCALL_COMPAT +#define __SCC (_cond, _nr, _sys, _comp) __SC(_cond, _nr, _comp) +#else +#define __SCC (_cond, _nr, _sys, _comp) __SC(_cond, _nr, _sys) +#endif +#endif +#if __BITS_PER_LONG ==32 || defined(__SYSCALL_COMPAT)#define __SC_3264 (_nr, _32, _64) __SYSCALL(_nr, _32) +#define __SYSCALL_32 (_nr, _sys) __SYSCALL(__NR_ ## _nr, _sys) +#define __SYSCALL_64 (_nr, _sys)#else #define __SC_3264 (_nr, _32, _64) __SYSCALL(_nr, _64) +#define __SYSCALL_32 (_nr, _sys) +#define __SYSCALL_64 (_nr, _sys) __SYSCALL(__NR_ ## _nr, _sys) +#endif + +#if defined(__ARCH_WANT_TIME32_SYSCALLS) +#define __SYSCALL_time32 (_nr, _sys) __SYSCALL_32(__NR_ ## _nr, _sys) +#else +#define __SYSCALL_time32 (_nr, _sys)#endif #ifdef __SYSCALL_COMPAT
@@ -41,7 +63,8 @@ __SYSCALL(__NR_io_cancel, sys_io_cancel)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_io_getevents 4 -__SC_3264(__NR_io_getevents, sys_io_getevents_time32, sys_io_getevents) +__SC(time32, io_getevents, sys_io_getevents_time32) +__SC(64, io_getevents, sys_io_getevents)#endif #define __NR_setxattr 5
@@ -190,9 +213,11 @@ __SYSCALL(__NR3264_sendfile, sys_sendfile64)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_pselect6 72 -__SC_COMP_3264(__NR_pselect6, sys_pselect6_time32, sys_pselect6, compat_sys_pselect6_time32) +__SCC(time32, pselect6, sys_pselect6_time32, compat_sys_pselect6_time32) +__SC(64, pselect6, sys_pselect6)#define __NR_ppoll 73 -__SC_COMP_3264(__NR_ppoll, sys_ppoll_time32, sys_ppoll, compat_sys_ppoll_time32) +__SCC(time32, ppoll, sys_ppoll_time32, compat_sys_ppoll_time32) +__SC(64, ppoll, sys_ppoll)#endif #define __NR_signalfd4 74
@@ -235,16 +260,17 @@ __SYSCALL(__NR_timerfd_create, sys_timerfd_create)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_timerfd_settime 86 -__SC_3264 (__NR_timerfd_settime, sys_timerfd_settime32, \ - sys_timerfd_settime) +__SC(time32, timerfd_settime, sys_timerfd_settime32) +__SC(64, timerfd_settime, sys_timerfd_settime)#define __NR_timerfd_gettime 87 -__SC_3264 (__NR_timerfd_gettime, sys_timerfd_gettime32, \ - sys_timerfd_gettime) +__SC(time32, timerfd_gettime, sys_timerfd_gettime32) +__SC(64, timerfd_gettime, sys_timerfd_gettime)#endif #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_utimensat 88 -__SC_3264(__NR_utimensat, sys_utimensat_time32, sys_utimensat) +__SC(time32, utimensat, sys_utimensat_time32) +__SC(64, utimensat, sys_utimensat)#endif #define __NR_acct 89
@@ -268,7 +294,8 @@ __SYSCALL(__NR_unshare, sys_unshare)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_futex 98 -__SC_3264(__NR_futex, sys_futex_time32, sys_futex) +__SC(time32, futex, sys_futex_time32) +__SC(64, futex, sys_futex)#endif #define __NR_set_robust_list 99
@@ -280,7 +307,8 @@ __SC_COMP(__NR_get_robust_list, sys_get_robust_list, \#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_nanosleep 101 -__SC_3264(__NR_nanosleep, sys_nanosleep_time32, sys_nanosleep) +__SC(time32, nanosleep, sys_nanosleep_time32) +__SC(64, nanosleep, sys_nanosleep)#endif #define __NR_getitimer 102
@@ -298,7 +326,8 @@ __SC_COMP(__NR_timer_create, sys_timer_create, compat_sys_timer_create)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_timer_gettime 108 -__SC_3264(__NR_timer_gettime, sys_timer_gettime32, sys_timer_gettime) +__SC(time32, timer_gettime, sys_timer_gettime32) +__SC(64, timer_gettime, sys_timer_gettime)#endif #define __NR_timer_getoverrun 109
@@ -306,7 +335,8 @@ __SYSCALL(__NR_timer_getoverrun, sys_timer_getoverrun)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_timer_settime 110 -__SC_3264(__NR_timer_settime, sys_timer_settime32, sys_timer_settime) +__SC(time32, timer_settime, sys_timer_settime32) +__SC(64, timer_settime, sys_timer_settime)#endif #define __NR_timer_delete 111
@@ -314,14 +344,17 @@ __SYSCALL(__NR_timer_delete, sys_timer_delete)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_clock_settime 112 -__SC_3264(__NR_clock_settime, sys_clock_settime32, sys_clock_settime) +__SC(time32, clock_settime, sys_clock_settime32) +__SC(64, clock_settime, sys_clock_settime)#define __NR_clock_gettime 113 -__SC_3264(__NR_clock_gettime, sys_clock_gettime32, sys_clock_gettime) +__SC(time32, clock_gettime, sys_clock_gettime32) +__SC(64, clock_gettime, sys_clock_gettime)#define __NR_clock_getres 114 -__SC_3264(__NR_clock_getres, sys_clock_getres_time32, sys_clock_getres) +__SC(time32, clock_getres, sys_clock_getres_time32) +__SC(64, clock_getres, sys_clock_getres)#define __NR_clock_nanosleep 115 -__SC_3264 (__NR_clock_nanosleep, sys_clock_nanosleep_time32, \ - sys_clock_nanosleep) +__SC(time32, clock_nanosleep, sys_clock_nanosleep_time32) +__SC(64, clock_nanosleep, sys_clock_nanosleep)#endif #define __NR_syslog 116
@@ -351,8 +384,8 @@ __SYSCALL(__NR_sched_get_priority_min, sys_sched_get_priority_min)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_sched_rr_get_interval 127 -__SC_3264 (__NR_sched_rr_get_interval, sys_sched_rr_get_interval_time32, \ - sys_sched_rr_get_interval) +__SC(time32, sched_rr_get_interval, sys_sched_rr_get_interval_time32) +__SC(64, sched_rr_get_interval, sys_sched_rr_get_interval)#endif #define __NR_restart_syscall 128
@@ -376,8 +409,8 @@ __SC_COMP(__NR_rt_sigpending, sys_rt_sigpending, compat_sys_rt_sigpending)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_rt_sigtimedwait 137 -__SC_COMP_3264 (__NR_rt_sigtimedwait, sys_rt_sigtimedwait_time32, \ - sys_rt_sigtimedwait, compat_sys_rt_sigtimedwait_time32) +__SCC(time32, rt_sigtimedwait, sys_rt_sigtimedwait_time32, compat_sys_rt_sigtimedwait_time32) +__SC(64, rt_sigtimedwait, sys_rt_sigtimedwait)#endif #define __NR_rt_sigqueueinfo 138
@@ -451,11 +484,14 @@ __SYSCALL(__NR_getcpu, sys_getcpu)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_gettimeofday 169 -__SC_COMP(__NR_gettimeofday, sys_gettimeofday, compat_sys_gettimeofday) +__SCC(time32, gettimeofday, sys_gettimeofday, compat_sys_gettimeofday) +__SC(64, gettimeofday, sys_gettimeofday)#define __NR_settimeofday 170 -__SC_COMP(__NR_settimeofday, sys_settimeofday, compat_sys_settimeofday) +__SCC(time32, settimeofday, sys_settimeofday, compat_sys_settimeofday) +__SC(64, settimeofday, sys_settimeofday)#define __NR_adjtimex 171 -__SC_3264(__NR_adjtimex, sys_adjtimex_time32, sys_adjtimex) +__SC(time32, adjtimex, sys_adjtimex_time32) +__SC(64, adjtimex, sys_adjtimex)#endif #define __NR_getpid 172
@@ -481,10 +517,11 @@ __SYSCALL(__NR_mq_unlink, sys_mq_unlink)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_mq_timedsend 182 -__SC_3264(__NR_mq_timedsend, sys_mq_timedsend_time32, sys_mq_timedsend) +__SC(time32, mq_timedsend, sys_mq_timedsend_time32) +__SC(64, mq_timedsend, sys_mq_timedsend)#define __NR_mq_timedreceive 183 -__SC_3264 (__NR_mq_timedreceive, sys_mq_timedreceive_time32, \ - sys_mq_timedreceive) +__SC(time32, mq_timedreceive, sys_mq_timedreceive_time32) +__SC(64, mq_timedreceive, sys_mq_timedreceive)#endif #define __NR_mq_notify 184
@@ -506,7 +543,8 @@ __SC_COMP(__NR_semctl, sys_semctl, compat_sys_semctl)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_semtimedop 192 -__SC_3264(__NR_semtimedop, sys_semtimedop_time32, sys_semtimedop) +__SC(time32, semtimedop, sys_semtimedop_time32) +__SC(64, semtimedop, sys_semtimedop)#endif #define __NR_semop 193
@@ -618,7 +656,8 @@ __SYSCALL(__NR_accept4, sys_accept4)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_recvmmsg 243 -__SC_COMP_3264(__NR_recvmmsg, sys_recvmmsg_time32, sys_recvmmsg, compat_sys_recvmmsg_time32) +__SCC(time32, recvmmsg, sys_recvmmsg_time32, compat_sys_recvmmsg_time32) +__SC(64, recvmmsg, sys_recvmmsg)#endif /*
@@ -629,7 +668,8 @@ __SC_COMP_3264(__NR_recvmmsg, sys_recvmmsg_time32, sys_recvmmsg, compat_sys_recv#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_wait4 260 -__SC_COMP(__NR_wait4, sys_wait4, compat_sys_wait4) +__SCC(time32, wait4, sys_wait4, compat_sys_wait4) +__SC(64, wait4, sys_wait4)#endif #define __NR_prlimit64 261
@@ -645,7 +685,8 @@ __SYSCALL(__NR_open_by_handle_at, sys_open_by_handle_at)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_clock_adjtime 266 -__SC_3264(__NR_clock_adjtime, sys_clock_adjtime32, sys_clock_adjtime) +__SC(time32, clock_adjtime, sys_clock_adjtime32) +__SC(64, clock_adjtime, sys_clock_adjtime)#endif #define __NR_syncfs 267
@@ -701,7 +742,8 @@ __SYSCALL(__NR_statx, sys_statx)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_io_pgetevents 292 -__SC_COMP_3264(__NR_io_pgetevents, sys_io_pgetevents_time32, sys_io_pgetevents, compat_sys_io_pgetevents) +__SCC(time32, io_pgetevents, sys_io_pgetevents_time32, compat_sys_io_pgetevents) +__SC(64, io_pgetevents, sys_io_pgetevents)#endif #define __NR_rseq 293
@@ -713,45 +755,45 @@ __SYSCALL(__NR_kexec_file_load, sys_kexec_file_load)#if defined(__SYSCALL_COMPAT) || __BITS_PER_LONG ==32 #define __NR_clock_gettime64 403 -__SYSCALL(__NR_clock_gettime64, sys_clock_gettime) +__SC(32, clock_gettime64, sys_clock_gettime)#define __NR_clock_settime64 404 -__SYSCALL(__NR_clock_settime64, sys_clock_settime) +__SC(32, clock_settime64, sys_clock_settime)#define __NR_clock_adjtime64 405 -__SYSCALL(__NR_clock_adjtime64, sys_clock_adjtime) +__SC(32, clock_adjtime64, sys_clock_adjtime)#define __NR_clock_getres_time64 406 -__SYSCALL(__NR_clock_getres_time64, sys_clock_getres) +__SC(32, clock_getres_time64, sys_clock_getres)#define __NR_clock_nanosleep_time64 407 -__SYSCALL(__NR_clock_nanosleep_time64, sys_clock_nanosleep) +__SC(32, clock_nanosleep_time64, sys_clock_nanosleep)#define __NR_timer_gettime64 408 -__SYSCALL(__NR_timer_gettime64, sys_timer_gettime) +__SC(32, timer_gettime64, sys_timer_gettime)#define __NR_timer_settime64 409 -__SYSCALL(__NR_timer_settime64, sys_timer_settime) +__SC(32, timer_settime64, sys_timer_settime)#define __NR_timerfd_gettime64 410 -__SYSCALL(__NR_timerfd_gettime64, sys_timerfd_gettime) +__SC(32, timerfd_gettime64, sys_timerfd_gettime)#define __NR_timerfd_settime64 411 -__SYSCALL(__NR_timerfd_settime64, sys_timerfd_settime) +__SC(32, timerfd_settime64, sys_timerfd_settime)#define __NR_utimensat_time64 412 -__SYSCALL(__NR_utimensat_time64, sys_utimensat) +__SC(32, utimensat_time64, sys_utimensat)#define __NR_pselect6_time64 413 -__SC_COMP(__NR_pselect6_time64, sys_pselect6, compat_sys_pselect6_time64) +__SCC(32, pselect6_time64, sys_pselect6, compat_sys_pselect6_time64)#define __NR_ppoll_time64 414 -__SC_COMP(__NR_ppoll_time64, sys_ppoll, compat_sys_ppoll_time64) +__SCC(32, ppoll_time64, sys_ppoll, compat_sys_ppoll_time64)#define __NR_io_pgetevents_time64 416 -__SYSCALL(__NR_io_pgetevents_time64, sys_io_pgetevents, compat_sys_io_pgetevents_time64) +__SCC(32, io_pgetevents_time64, sys_io_pgetevents, compat_sys_io_pgetevents_time64)#define __NR_recvmmsg_time64 417 -__SC_COMP(__NR_recvmmsg_time64, sys_recvmmsg, compat_sys_recvmmsg_time64) +__SCC(32, recvmmsg_time64, sys_recvmmsg, compat_sys_recvmmsg_time64)#define __NR_mq_timedsend_time64 418 -__SYSCALL(__NR_mq_timedsend_time64, sys_mq_timedsend) +__SC(32, mq_timedsend_time64, sys_mq_timedsend)#define __NR_mq_timedreceive_time64 419 -__SYSCALL(__NR_mq_timedreceive_time64, sys_mq_timedreceive) +__SC(32, mq_timedreceive_time64, sys_mq_timedreceive)#define __NR_semtimedop_time64 420 -__SYSCALL(__NR_semtimedop_time64, sys_semtimedop) +__SC(32, semtimedop_time64, sys_semtimedop)#define __NR_rt_sigtimedwait_time64 421 -__SC_COMP(__NR_rt_sigtimedwait_time64, sys_rt_sigtimedwait, compat_sys_rt_sigtimedwait_time64) +__SCC(32, rt_sigtimedwait_time64, sys_rt_sigtimedwait, compat_sys_rt_sigtimedwait_time64)#define __NR_futex_time64 422 -__SYSCALL(__NR_futex_time64, sys_futex) +__SC(32, futex_time64, sys_futex)#define __NR_sched_rr_get_interval_time64 423 -__SYSCALL(__NR_sched_rr_get_interval_time64, sys_sched_rr_get_interval) +__SC(32, sched_rr_get_interval_time64, sys_sched_rr_get_interval)#endif #define __NR_pidfd_send_signal 424
Signature · 1 line
2.39.2
PATCH 15/15 linux/syscalls.h: add missing __user annotations
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
A couple of declarations in linux/syscalls.h are missing __user annotations on their pointers, which can lead to warnings from sparse because these don't match the implementation that have the correct address space annotations.
--- include/linux/syscalls.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
include/linux/syscalls.h +9 -9
@@ -322,13 +322,13 @@ asmlinkage long sys_io_pgetevents(aio_context_t ctx_id,long nr, struct io_event __user *events, struct __kernel_timespec __user *timeout, - const struct __aio_sigset *sig); + const struct __aio_sigset __user *sig);asmlinkage long sys_io_pgetevents_time32 (aio_context_t ctx_id,long min_nr,long nr,struct io_event __user *events,struct old_timespec32 __user *timeout, -const struct __aio_sigset *sig); +const struct __aio_sigset __user *sig);asmlinkage long sys_io_uring_setup (u32 entries,struct io_uring_params __user *p); asmlinkage long sys_io_uring_enter(unsigned int fd, u32 to_submit,
@@ -441,7 +441,7 @@ asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group);asmlinkage long sys_openat (int dfd,const char __user *filename,int flags,umode_t mode);asmlinkage long sys_openat2 (int dfd,const char __user *filename, -struct open_how *how,size_t size); +struct open_how __user *how,size_t size);asmlinkage long sys_close (unsigned int fd);asmlinkage long sys_close_range (unsigned int fd,unsigned int max_fd,unsigned int flags);
@@ -555,7 +555,7 @@ asmlinkage long sys_get_robust_list(int pid,asmlinkage long sys_set_robust_list (struct robust_list_head __user *head,size_t len); -asmlinkage long sys_futex_waitv (struct futex_waitv *waiters, +asmlinkage long sys_futex_waitv (struct futex_waitv __user *waiters,unsigned int nr_futexes,unsigned int flags,struct __kernel_timespec __user *timeout,clockid_t clockid);
@@ -907,7 +907,7 @@ asmlinkage long sys_seccomp(unsigned int op, unsigned int flags,asmlinkage long sys_getrandom (char __user *buf,size_t count,unsigned int flags);asmlinkage long sys_memfd_create (const char __user *uname_ptr,unsigned int flags); -asmlinkage long sys_bpf (int cmd,union bpf_attr *attr,unsigned int size); +asmlinkage long sys_bpf (int cmd,union bpf_attr __user *attr,unsigned int size);asmlinkage long sys_execveat (int dfd,const char __user *filename,const char __user *const __user *argv,const char __user *const __user *envp,int flags);
@@ -960,11 +960,11 @@ asmlinkage long sys_cachestat(unsigned int fd,struct cachestat_range __user *cstat_range, struct cachestat __user *cstat, unsigned int flags);asmlinkage long sys_map_shadow_stack (unsigned long addr,unsigned long size,unsigned int flags); -asmlinkage long sys_lsm_get_self_attr (unsigned int attr,struct lsm_ctx *ctx, -u32 *size,u32 flags); -asmlinkage long sys_lsm_set_self_attr (unsigned int attr,struct lsm_ctx *ctx, +asmlinkage long sys_lsm_get_self_attr (unsigned int attr,struct lsm_ctx __user *ctx, +u32 __user *size,u32 flags); +asmlinkage long sys_lsm_set_self_attr (unsigned int attr,struct lsm_ctx __user *ctx,u32 size,u32 flags); -asmlinkage long sys_lsm_list_modules (u64 *ids,u32 *size,u32 flags); +asmlinkage long sys_lsm_list_modules (u64 __user *ids,u32 __user *size,u32 flags);/* * Architecture-specific system calls
Signature · 1 line
2.39.2
Re: [PATCH 06/15] parisc: use correct compat recv/recvfrom syscalls
In reply to Arnd BergmannQuoted 10 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Johannes missed parisc back when he introduced the compat version of these syscalls, so receiving cmsg messages that require a compat conversion is still broken.
Use the correct calls like the other architectures do.
Fixes 1dacc76d0014 ("net/compat/wext: send different messages to compat tasks")Signed-off-by Arnd Bergmann <[email protected]>
Nice catch, Arnd!
I'll add a backport tag and take this patch through the parisc git tree.
Thank you!
Helge
Quoted 26 lines
--- arch/parisc/kernel/syscalls/syscall.tbl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/parisc/kernel/syscalls/syscall.tbl +2
-2@@ -108,7 +108,7 @@ 95 common fchown sys_fchown 96 common getpriority sys_getpriority 97 common setpriority sys_setpriority -98 common recv sys_recv +98 common recv sys_recv compat_sys_recv 99 common statfs sys_statfs compat_sys_statfs 100 common fstatfs sys_fstatfs compat_sys_fstatfs 101 common stat64 sys_stat64@@ -135,7 +135,7 @@ 120 common clone sys_clone_wrapper 121 common setdomainname sys_setdomainname 122 common sendfile sys_sendfile compat_sys_sendfile -123 common recvfrom sys_recvfrom +123 common recvfrom sys_recvfrom compat_sys_recvfrom 124 32 adjtimex sys_adjtimex_time32 124 64 adjtimex sys_adjtimex 125 common mprotect sys_mprotect
Helge Deller
maintainerRe: [PATCH 07/15] parisc: use generic sys_fanotify_mark implementation
In reply to Arnd BergmannQuoted 7 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The
sys_fanotify_mark()syscall on parisc uses the reverse word order for the two halves of the 64-bit argument compared to all syscalls on all 32-bit architectures. As far as I can tell, the problem is that the function arguments on parisc are sorted backwards (26, 25, 24, 23, ...) compared to everyone else,
r26 is arg0, r25 is arg1, and so on.
I'm not sure I would call this "sorted backwards".
I think the reason is simply that hppa is the only 32-bit big-endian arch left...
Quoted 9 lines
so the calling conventions of using an
even/odd register pair in native word order result in the lower word coming first in function arguments, matching the expected behavior on little-endian architectures. The system call conventions however ended up matching what the other 32-bit architectures do.A glibc cleanup in 2020 changed the userspace behavior in a way that handles all architectures consistently, but this inadvertently broke parisc32 by changing to the same method as everyone else.
I appreciate such cleanups to make arches consistent. But it's bad if breakages aren't noticed or reported then...
Quoted 8 lines
The change made it into glibc-2.35 and subsequently into debian 12 (bookworm), which is the latest stable release. This means we need to choose between reverting the glibc change or changing the kernel to match it again, but either hange will leave some systems broken.
Pick the option that is more likely to help current and future users and change the kernel to match current glibc.
Agreed (assuming we have really a problem on parisc).
Quoted 11 lines
This also
means the behavior is now consistent across architectures, but it breaks running new kernels with old glibc builds before 2.35.Cc Adhemerval Zanella <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>---
I found this through code inspection, please double-check to make sure I got the bug and the fix right.
The patch looks good at first sight.
I'll pick it up in my parisc git tree and will do some testing the next few days and then push forward for 6.11 when it opens....
Thank you!!
Helge
Quoted 50 lines
The alternative is to fix this by reverting glibc back to the unusual behavior.
--- arch/parisc/Kconfig | 1 + arch/parisc/kernel/sys_parisc32.c | 9 --------- arch/parisc/kernel/syscalls/syscall.tbl | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-)arch/parisc/Kconfig +1
-0@@ -16,6 +16,7 @@ config PARISC select ARCH_HAS_UBSAN select ARCH_HAS_PTE_SPECIAL select ARCH_NO_SG_CHAIN + select ARCH_SPLIT_ARG64 if !64BIT select ARCH_SUPPORTS_HUGETLBFS if PA20 select ARCH_SUPPORTS_MEMORY_FAILURE select ARCH_STACKWALKarch/parisc/kernel/sys_parisc32.c +0
-9@@ -23,12 +23,3 @@ asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23, current->comm, current->pid, r20);return -ENOSYS ; } - -asmlinkage long sys32_fanotify_mark (compat_int_t fanotify_fd,compat_uint_t flags, -compat_uint_t mask0,compat_uint_t mask1,compat_int_t dfd, -const char __user * pathname) -{ -return sys_fanotify_mark (fanotify_fd, flags, - ((__u64 )mask1 <<32 ) | mask0, - dfd, pathname); -}arch/parisc/kernel/syscalls/syscall.tbl +1
-1@@ -364,7 +364,7 @@ 320 common accept4 sys_accept4 321 common prlimit64 sys_prlimit64 322 common fanotify_init sys_fanotify_init -323 common fanotify_mark sys_fanotify_mark sys32_fanotify_mark +323 common fanotify_mark sys_fanotify_mark compat_sys_fanotify_mark 324 32 clock_adjtime sys_clock_adjtime32 324 64 clock_adjtime sys_clock_adjtime 325 common name_to_handle_at sys_name_to_handle_at
Re: [PATCH 07/15] parisc: use generic sys_fanotify_mark implementation
Quoted 13 lines · Helge Deller
[Vous ne recevez pas souvent de courriers de [email protected]. Découvrez pourquoi ceci est important à
https://aka.ms/LearnAboutSenderIdentification ]Quoted 7 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The
sys_fanotify_mark()syscall on parisc uses the reverse word order for the two halves of the 64-bit argument compared to all syscalls on all 32-bit architectures. As far as I can tell, the problem is that the function arguments on parisc are sorted backwards (26, 25, 24, 23, ...) compared to everyone else,
Quoted 4 lines
r26 is arg0, r25 is arg1, and so on.
I'm not sure I would call this "sorted backwards".
I think the reason is simply that hppa is the only 32-bit big-endian arch left...
powerpc/32 is big-endian: r3 is arg0, r4 is arg1, ... r10 is arg7.
In case of a 64bits arg, r3 is the high part and r4 is the low part.
Christophe
Quoted 104 lines
Quoted 10 lines
so the calling conventions of using an
even/odd register pair in native word order result in the lower word coming first in function arguments, matching the expected behavior on little-endian architectures. The system call conventions however ended up matching what the other 32-bit architectures do.A glibc cleanup in 2020 changed the userspace behavior in a way that handles all architectures consistently, but this inadvertently broke parisc32 by changing to the same method as everyone else.
I appreciate such cleanups to make arches consistent. But it's bad if breakages aren't noticed or reported then...
Quoted 8 lines
The change made it into glibc-2.35 and subsequently into debian 12 (bookworm), which is the latest stable release. This means we need to choose between reverting the glibc change or changing the kernel to match it again, but either hange will leave some systems broken.
Pick the option that is more likely to help current and future users and change the kernel to match current glibc.
Agreed (assuming we have really a problem on parisc).
Quoted 8 lines
This also
means the behavior is now consistent across architectures, but it breaks running new kernels with old glibc builds before 2.35.Link:
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=d150181d73d9
Link:
https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/arch/parisc/kernel/sys_parisc.c?h=57b1dfbd5b4a39dQuoted 5 lines
Cc Adhemerval Zanella <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>---
I found this through code inspection, please double-check to make sure I got the bug and the fix right.The patch looks good at first sight.
I'll pick it up in my parisc git tree and will do some testing the next few days and then push forward for 6.11 when it opens....Thank you!!
Helge
Quoted 56 lines
The alternative is to fix this by reverting glibc back to the unusual behavior.
--- arch/parisc/Kconfig | 1 + arch/parisc/kernel/sys_parisc32.c | 9 --------- arch/parisc/kernel/syscalls/syscall.tbl | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-)arch/parisc/Kconfig +1
-0@@ -16,6 +16,7 @@ config PARISC select ARCH_HAS_UBSAN select ARCH_HAS_PTE_SPECIAL select ARCH_NO_SG_CHAIN + select ARCH_SPLIT_ARG64 if !64BIT select ARCH_SUPPORTS_HUGETLBFS if PA20 select ARCH_SUPPORTS_MEMORY_FAILURE select ARCH_STACKWALKarch/parisc/kernel/sys_parisc32.c +0
-2@@ -23,12 +23,3 @@ asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23, current->comm, current->pid, r20);return -ENOSYS ; } - -asmlinkage long sys32_fanotify_mark(compat_int_t fanotify_fd,
compat_uint_tflags,arch/parisc/kernel/sys_parisc32.c +0
-7- compat_uint_t mask0, compat_uint_t mask1, compat_int_t dfd, - const char __user * pathname) -{ - return sys_fanotify_mark(fanotify_fd, flags, - ((__u64)mask1 << 32) | mask0, -dfd ,pathname ); -}arch/parisc/kernel/syscalls/syscall.tbl +0
-1@@ -364,7 +364,7 @@ 320 common accept4 sys_accept4 321 common prlimit64 sys_prlimit64 322 common fanotify_init sys_fanotify_init -323 common fanotify_mark sys_fanotify_mark
sys32_fanotify_mark
+323 commonfanotify_marksys_fanotify_markcompat_sys_fanotify_mark324 32 clock_adjtime sys_clock_adjtime32 324 64 clock_adjtime sys_clock_adjtime 325 common name_to_handle_at sys_name_to_handle_at
Arnd Bergmann
maintainerRe: [PATCH 07/15] parisc: use generic sys_fanotify_mark implementation
Quoted 14 lines · LEROY Christophe
Quoted 13 lines · Helge Deller
[Vous ne recevez pas souvent de courriers de [email protected]. Découvrez pourquoi ceci est important à
https://aka.ms/LearnAboutSenderIdentification ]Quoted 7 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The
sys_fanotify_mark()syscall on parisc uses the reverse word order for the two halves of the 64-bit argument compared to all syscalls on all 32-bit architectures. As far as I can tell, the problem is that the function arguments on parisc are sorted backwards (26, 25, 24, 23, ...) compared to everyone else,
Quoted 6 lines
Quoted 4 lines
r26 is arg0, r25 is arg1, and so on.
I'm not sure I would call this "sorted backwards".
I think the reason is simply that hppa is the only 32-bit big-endian arch left...powerpc/32 is big-endian: r3 is arg0, r4 is arg1, ... r10 is arg7.
Right, I'm pretty sure the ordering is the same on arm, mips, s390, m68k, openrisc, sh and sparc when running 32-bit big-endian code.
It's more likely to be related to the upward growing stack. I checked the gcc sources and found that out of the 50 supported architectures, ARGS_GROW_DOWNWARD is set on everything except for gcn, stormy16 and 32-bit parisc. The other two are little-endian though. STACK_GROWS_DOWNWARD in turn is set on everything other than parisc (both 32-bit and 64-bit).
Arnd
Re: [PATCH 01/15] ftruncate: pass a signed offset
In reply to Arnd BergmannQuoted 10 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The old
ftruncate()syscall, using the 32-bitoff_tmisses a sign extension when called in compat mode on 64-bit architectures. As a result, passing a negative length accidentally succeeds in truncating to file size between 2GiB and 4GiB.Changing the type of the compat syscall to the signed
compat_off_tchanges the behavior so it instead returns-EINVAL.
Quoted 8 lines
The native entry point, the
truncate()syscall and the correspondingloff_tbased variants are all correct already and do not suffer from this mistake.Fixes 3f6d078d4acc ("fix compat truncate/ftruncate")Signed-off-by Arnd Bergmann <[email protected]>---
Looks good to me,
Re: [PATCH 03/15] mips: fix compat_sys_lseek syscall
In reply to Arnd BergmannQuoted 28 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
This is almost compatible, but passing a negative offset should result in a EINVAL error, but on mips o32 compat mode would seek to a large 32-bit byte offset.
Use
compat_sys_lseek()to correctly sign-extend the argument.Signed-off-by Arnd Bergmann <[email protected]>--- arch/mips/kernel/syscalls/syscall_o32.tbl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/kernel/syscalls/syscall_o32.tbl +1
-1@@ -27,7 +27,7 @@ 17 o32 break sys_ni_syscall # 18 was sys_stat 18 o32 unused18 sys_ni_syscall -19 o32 lseek sys_lseek +19 o32 lseek sys_lseek compat_sys_lseek 20 o32 getpid sys_getpid 21 o32 mount sys_mount 22 o32 umount sys_oldumountSignature · 1 line
2.39.2
applied to mips-fixes.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
John Paul Adrian Glaubitz
maintainerRe: [PATCH 09/15] sh: rework sync_file_range ABI
In reply to Arnd BergmannHi Arnd,
thanks for your patch!
Quoted 3 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The unusual function calling conventions on superh ended up causing
^^^^^^
It's spelled SuperH
Quoted 29 lines
sync_file_rangeto have the wrong argument order, with the 'flags' argument getting sorted before 'nbytes' by the compiler.In userspace, I found that musl, glibc, uclibc and strace all expect the normal calling conventions with 'nbytes' last, so changing the kernel to match them should make all of those work.
In order to be able to also fix libc implementations to work with existing kernels, they need to be able to tell which ABI is used. An easy way to do this is to add yet another system call using the
sync_file_range2ABI that works the same on all architectures.Old user binaries can now work on new kernels, and new binaries can try the new
sync_file_range2()to work with new kernels or fall back to the oldsync_file_range()version if that doesn't exist.Fixes 75c92acdd5b1 ("sh: Wire up new syscalls.")Signed-off-by Arnd Bergmann <[email protected]>--- arch/sh/kernel/sys_sh32.c | 11 +++++++++++ arch/sh/kernel/syscalls/syscall.tbl | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-)arch/sh/kernel/sys_sh32.c +0
-0
arch/sh/kernel/sys_sh32.c asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, · line 64
Quoted 6 lines
arch/sh/kernel/sys_sh32.c +3
-0@@ -59,3 +59,14 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, (u64)len0 << 32 | len1, advice);#endif } + +/* +* swap the arguments the way that libc wants it instead of
I think "swap the arguments to the order that libc wants them" would be easier to understand here.
Quoted 13 lines
arch/sh/kernel/sys_sh32.c +8
-0+* moving flags ahead of the 64-bit nbytes argument +*/ +SYSCALL_DEFINE6 (sh_sync_file_range6, int, fd,SC_ARG64 (offset), + SC_ARG64(nbytes), unsigned int, flags) +{ +return ksys_sync_file_range (fd,SC_VAL64 (loff_t, offset), +SC_VAL64 (loff_t, nbytes), flags); +}arch/sh/kernel/syscalls/syscall.tbl +0
-0
arch/sh/kernel/syscalls/syscall.tbl line 324
Quoted 5 lines
arch/sh/kernel/syscalls/syscall.tbl +1
-1@@ -321,7 +321,7 @@ 311 common set_robust_list sys_set_robust_list 312 common get_robust_list sys_get_robust_list 313 common splice sys_splice -314 common sync_file_range sys_sync_file_range +314 common sync_file_range sys_sh_sync_file_range6
^^^^^^ Why the suffix 6 here?
arch/sh/kernel/syscalls/syscall.tbl line 401
Quoted 11 lines
arch/sh/kernel/syscalls/syscall.tbl +1
-0315 common tee sys_tee 316 common vmsplice sys_vmsplice 317 common move_pages sys_move_pages@@ -395,6 +395,7 @@ 385 common pkey_alloc sys_pkey_alloc 386 common pkey_free sys_pkey_free 387 common rseq sys_rseq +388 common sync_file_range2 sys_sync_file_range2 # room for arch specific syscalls 393 common semget sys_semget 394 common semctl sys_semctl
I wonder how you discovered this bug. Did you look up the calling convention on SuperH and compare the argument order for the sys_sync_file_range system call documented there with the order in the kernel?
Did you also check what order libc uses? I would expect libc on SuperH misordering the arguments as well unless I am missing something. Or do we know that the code is actually currently broken?
Thanks,
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
John Paul Adrian Glaubitz
maintainerRe: [PATCH 07/15] parisc: use generic sys_fanotify_mark implementation
In reply to Helge DellerHi Helge and Arnd,
Quoted 3 lines · Helge Deller
The patch looks good at first sight.
I'll pick it up in my parisc git tree and will do some testing the next few days and then push forward for 6.11 when it opens....
Isn't this supposed to go in as one series or can arch maintainers actually pick the patches for their architecture and merge them individually?
If yes, I would prefer to do that for the SuperH patch as well as I usually prefer merging SuperH patches in my own tree.
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
John Paul Adrian Glaubitz
maintainerRe: [PATCH 07/15] parisc: use generic sys_fanotify_mark implementation
In reply to Arnd BergmannHi,
Quoted 6 lines · Arnd Bergmann
It's more likely to be related to the upward growing stack. I checked the gcc sources and found that out of the 50 supported architectures,
ARGS_GROW_DOWNWARDis set on everything except for gcn, stormy16 and 32-bit parisc. The other two are little-endian though.STACK_GROWS_DOWNWARDin turn is set on everything other than parisc (both 32-bit and 64-bit).
Wait a second! Does that mean that on 64-bit PA-RISC, the stack is actually growing downwards? If yes, that would be a strong argument for creating a 64-bit PA-RISC port in Debian and replacing the 32-bit port.
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Arnd Bergmann
maintainerRe: [PATCH 07/15] parisc: use generic sys_fanotify_mark implementation
In reply to John Paul Adrian GlaubitzQuoted 7 lines · John Paul Adrian Glaubitz
Hi Helge and Arnd,
Quoted 3 lines · Helge Deller
The patch looks good at first sight.
I'll pick it up in my parisc git tree and will do some testing the next few days and then push forward for 6.11 when it opens....
Quoted 5 lines
Isn't this supposed to go in as one series or can arch maintainers actually pick the patches for their architecture and merge them individually?
If yes, I would prefer to do that for the SuperH patch as well as I usually prefer merging SuperH patches in my own tree.
The patches are all independent of one another, except for a couple of context changes where multiple patches touch the same lines.
Feel free to pick up the sh patch directly, I'll just merge whatever is left in the end. I mainly want to ensure we can get all the bugfixes done for v6.10 so I can build my longer cleanup series on top of it for 6.11.
Arnd
John Paul Adrian Glaubitz
maintainerRe: [PATCH 07/15] parisc: use generic sys_fanotify_mark implementation
Quoted 2 lines · Arnd Bergmann
The patches are all independent of one another, except for a couple of context changes where multiple patches touch the same lines.
OK.
Quoted 4 lines
Feel free to pick up the sh patch directly, I'll just merge whatever is left in the end. I mainly want to ensure we can get all the bugfixes done for v6.10 so I can build my longer cleanup series on top of it for 6.11.
This series is still for 6.10?
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Arnd Bergmann
maintainerRe: [PATCH 09/15] sh: rework sync_file_range ABI
In reply to John Paul Adrian GlaubitzQuoted 6 lines · John Paul Adrian Glaubitz
Quoted 3 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The unusual function calling conventions on superh ended up causing
^^^^^^
It's spelled SuperH
Fixed now.
Quoted 6 lines
Quoted 6 lines
arch/sh/kernel/sys_sh32.c +0
-0@@ -59,3 +59,14 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, (u64)len0 << 32 | len1, advice);
Quoted 8 lines
arch/sh/kernel/sys_sh32.c asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, · line 64
Quoted 5 lines
arch/sh/kernel/sys_sh32.c +3
-0#endif } + +/* +* swap the arguments the way that libc wants it instead of I think "swap the arguments to the order that libc wants them" would be easier to understand here.
Done
Quoted 11 lines
arch/sh/kernel/syscalls/syscall.tbl line 324
Quoted 10 lines
arch/sh/kernel/syscalls/syscall.tbl +1
-1@@ -321,7 +321,7 @@ 311 common set_robust_list sys_set_robust_list 312 common get_robust_list sys_get_robust_list 313 common splice sys_splice -314 common sync_file_range sys_sync_file_range +314 common sync_file_range sys_sh_sync_file_range6^^^^^^
Quoted 1 line
Why the suffix 6 here?
In a later part of my cleanup, I'm consolidating all the copies of this function (arm64, mips, parisc, powerpc, s390, sh, sparc, x86) and picked the name sys_sync_file_range6() for common implementation.
I end up with four entry points here, so the naming is a bit confusing:
- sys_sync_file_range() is only used on 64-bit architectures, on x32 and on mips-n32. This uses four arguments, including two 64-bit wide ones.
- sys_sync_file_range2() continues to be used on arm, powerpc, xtensa and now on sh, hexagon and csky. I change the implementation to take six 32-bit arguments, but the ABI remains the same as before, with the flags before offset.
- sys_sync_file_range6() is used for most other 32-bit ABIs:
arc, m68k, microblaze, nios2, openrisc, parisc, s390, sh, sparc and x86. This also has six 32-bit arguments but in the default order (fd, offset, nbytes, flags).
- sys_sync_file_range7() is exclusive to mips-o32, this one has an unused argument and is otherwise the same as sys_sync_file_range6().
My plan is to then have some infrastructure to ensure userspace tools (libc, strace, qemu, rust, ...) use the same calling conventions as the kernel. I'm doing the same thing for all other syscalls that have architecture specific calling conventions, so far I'm using
fadvise64_64_7fanotify_mark6
truncate3
truncate4
ftruncate3
ftruncate4
fallocate6
pread5
pread6
pwrite5
pwrite6
preadv5
preadv6
pwritev5
pwritev6sync_file_range6fadvise64_64_2fadvise64_64_6fadvise64_5fadvise64_6
readahead4
readahead5
The last number here is usually the number of 32-bit arguments, except for fadvise64_64_2 that uses the same argument reordering trick as sync_file_range2.
I'm not too happy with the naming but couldn't come up with anything clearer either, so let me know if you have any ideas there.
Quoted 9 lines
Quoted 9 lines
arch/sh/kernel/syscalls/syscall.tbl +1
-0315 common tee sys_tee 316 common vmsplice sys_vmsplice 317 common move_pages sys_move_pages@@ -395,6 +395,7 @@ 385 common pkey_alloc sys_pkey_alloc 386 common pkey_free sys_pkey_free 387 common rseq sys_rseq +388 common sync_file_range2 sys_sync_file_range2 # room for arch specific syscalls
Quoted 8 lines
arch/sh/kernel/syscalls/syscall.tbl line 401
Quoted 2 lines
arch/sh/kernel/syscalls/syscall.tbl +0
-0393 common semget sys_semget 394 common semctl sys_semctlI wonder how you discovered this bug. Did you look up the calling convention on SuperH
and compare the argument order for thesys_sync_file_rangesystem call documented there
with the order in the kernel?
I had to categorize all architectures based on their calling conventions to see if 64-bit arguments need aligned pairs or not, so I wrote a set of simple C files that I compiled for all architectures to see in which cases they insert unused arguments or swap the order of the upper and lower halves.
SuperH, parisc and s390 are each slightly different from all the others here, so I ended up reading the ELF psABI docs and/or the compiler sources to be sure.
I also a lot of git history.
Quoted 5 lines
Did you also check what order libc uses? I would expect libc on SuperH misordering the
arguments as well unless I am missing something. Or do we know that the code is actually
currently broken?
Yes, I checked glibc, musl and uclibc-ng for all the cases in which the ABI made no sense, as well as to check that my analysis of the kernel sources matches the expectations of the libc.
Arnd
Arnd Bergmann
maintainerRe: [PATCH 07/15] parisc: use generic sys_fanotify_mark implementation
In reply to John Paul Adrian GlaubitzQuoted 7 lines · John Paul Adrian Glaubitz
Quoted 4 lines · Arnd Bergmann
Feel free to pick up the sh patch directly, I'll just merge whatever is left in the end. I mainly want to ensure we can get all the bugfixes done for v6.10 so I can build my longer cleanup series on top of it for 6.11.
This series is still for 6.10?
Yes, these are all the bugfixes that I think we want to backport to stable kernels, so it makes sense to merge them as quickly as possible. The actual stuff I'm working on will come as soon as I have it in a state for public review and won't need to be backported.
Arnd
Re: [PATCH 07/15] parisc: use generic sys_fanotify_mark implementation
In reply to John Paul Adrian GlaubitzQuoted 9 lines · John Paul Adrian Glaubitz
Hi,
Quoted 6 lines · Arnd Bergmann
It's more likely to be related to the upward growing stack. I checked the gcc sources and found that out of the 50 supported architectures,
ARGS_GROW_DOWNWARDis set on everything except for gcn, stormy16 and 32-bit parisc. The other two are little-endian though.STACK_GROWS_DOWNWARDin turn is set on everything other than parisc (both 32-bit and 64-bit).
Quoted 4 lines
Wait a second! Does that mean that on 64-bit PA-RISC, the stack is actually growing downwards? If yes, that would be a strong argument for creating a 64-bit PA-RISC port in Debian and replacing the 32-bit port.
No, the stack grows upward on both 32 and 64-bit parisc. But stack arguments grow upwards on 64-bit parisc. The argument pointer is needed to access these arguments. In 32-bit parisc, the argument pointer is at a fixed offset relative to the stack pointer and it can be eliminated.
Dave
Signature · 1 line
John David Anglin [email protected]
Re: [PATCH 12/15] s390: remove native mmap2() syscall
In reply to Arnd BergmannQuoted 6 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The
mmap2()syscall has never been used on 64-bit s390x and should have been removed as part of5a79859ae0f3("s390: remove 31 bit support").
Quoted 6 lines
Remove it now.
Signed-off-by Arnd Bergmann <[email protected]>--- arch/s390/kernel/syscall.c | 27 --------------------------- 1 file changed, 27 deletions(-)
Re: [PATCH 02/15] syscalls: fix compat_sys_io_pgetevents_time64 usage
In reply to Arnd BergmannQuoted 21 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Using
sys_io_pgetevents()as the entry point for compat mode tasks works almost correctly, but misses the sign extension for themin_nrand nr arguments.This was addressed on parisc by switching to
compat_sys_io_pgetevents_time64()in commit6431e92fc827("parisc:io_pgetevents_time64()needs compat syscall in 32-bit compat mode"), as well as by using more sophisticated system call wrappers on x86 and s390. However, arm64, mips, powerpc, sparc and riscv still have the same bug.Changes all of them over to use
compat_sys_io_pgetevents_time64()like parisc already does. This was clearly the intention when the function was originally added, but it got hooked up incorrectly in the tables.Fixes 48166e6ea47d ("y2038: add 64-bit time_t syscalls to all 32-bit architectures")Signed-off-by Arnd Bergmann <[email protected]>
Quoted 10 lines
--- arch/arm64/include/asm/unistd32.h | 2 +- arch/mips/kernel/syscalls/syscall_n32.tbl | 2 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 2 +- arch/powerpc/kernel/syscalls/syscall.tbl | 2 +- arch/s390/kernel/syscalls/syscall.tbl | 2 +- arch/sparc/kernel/syscalls/syscall.tbl | 2 +- arch/x86/entry/syscalls/syscall_32.tbl | 2 +- include/uapi/asm-generic/unistd.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-)
Re: [PATCH 07/15] parisc: use generic sys_fanotify_mark implementation
In reply to Arnd BergmannQuoted 7 lines · Arnd Bergmann
Quoted 6 lines · John Paul Adrian Glaubitz
Quoted 4 lines · Arnd Bergmann
Feel free to pick up the sh patch directly, I'll just merge whatever is left in the end. I mainly want to ensure we can get all the bugfixes done for v6.10 so I can build my longer cleanup series on top of it for 6.11.
Quoted 7 lines
Quoted 1 line
This series is still for 6.10?
Yes, these are all the bugfixes that I think we want to backport to stable kernels, so it makes sense to merge them as quickly as possible. The actual stuff I'm working on will come as soon as I have it in a state for public review and won't need to be backported.
Ah, OK.... in that case would you please keep the two parisc patches in your git tree? I didn't plan to send a new pull request during v6.10, so it's easier for me if you keep them and send them together with your other remaining patches. (I'll drop them now from the parisc tree)
I tested both patches, so you may add:
Thank you!
Helge
Rich Felker
maintainerRe: [musl] Re: [PATCH 09/15] sh: rework sync_file_range ABI
In reply to John Paul Adrian GlaubitzQuoted 86 lines · John Paul Adrian Glaubitz
Hi Arnd,
thanks for your patch!
Quoted 3 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The unusual function calling conventions on superh ended up causing
^^^^^^
It's spelled SuperHQuoted 29 lines
sync_file_rangeto have the wrong argument order, with the 'flags' argument getting sorted before 'nbytes' by the compiler.In userspace, I found that musl, glibc, uclibc and strace all expect the normal calling conventions with 'nbytes' last, so changing the kernel to match them should make all of those work.
In order to be able to also fix libc implementations to work with existing kernels, they need to be able to tell which ABI is used. An easy way to do this is to add yet another system call using the
sync_file_range2ABI that works the same on all architectures.Old user binaries can now work on new kernels, and new binaries can try the new
sync_file_range2()to work with new kernels or fall back to the oldsync_file_range()version if that doesn't exist.Fixes 75c92acdd5b1 ("sh: Wire up new syscalls.")Signed-off-by Arnd Bergmann <[email protected]>--- arch/sh/kernel/sys_sh32.c | 11 +++++++++++ arch/sh/kernel/syscalls/syscall.tbl | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-)arch/sh/kernel/sys_sh32.c +0
-0arch/sh/kernel/sys_sh32.c asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, · line 64
Quoted 6 lines
arch/sh/kernel/sys_sh32.c +3
-0@@ -59,3 +59,14 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, (u64)len0 << 32 | len1, advice);#endif } + +/* +* swap the arguments the way that libc wants it instead of I think "swap the arguments to the order that libc wants them" would be easier to understand here.
Quoted 13 lines
arch/sh/kernel/sys_sh32.c +8
-0+* moving flags ahead of the 64-bit nbytes argument +*/ +SYSCALL_DEFINE6 (sh_sync_file_range6, int, fd,SC_ARG64 (offset), + SC_ARG64(nbytes), unsigned int, flags) +{ +return ksys_sync_file_range (fd,SC_VAL64 (loff_t, offset), +SC_VAL64 (loff_t, nbytes), flags); +}arch/sh/kernel/syscalls/syscall.tbl +0
-0arch/sh/kernel/syscalls/syscall.tbl line 324
Quoted 5 lines
arch/sh/kernel/syscalls/syscall.tbl +1
-1@@ -321,7 +321,7 @@ 311 common set_robust_list sys_set_robust_list 312 common get_robust_list sys_get_robust_list 313 common splice sys_splice -314 common sync_file_range sys_sync_file_range +314 common sync_file_range sys_sh_sync_file_range6^^^^^^ Why the suffix 6 here?arch/sh/kernel/syscalls/syscall.tbl line 401
Quoted 11 lines
arch/sh/kernel/syscalls/syscall.tbl +1
-0315 common tee sys_tee 316 common vmsplice sys_vmsplice 317 common move_pages sys_move_pages@@ -395,6 +395,7 @@ 385 common pkey_alloc sys_pkey_alloc 386 common pkey_free sys_pkey_free 387 common rseq sys_rseq +388 common sync_file_range2 sys_sync_file_range2 # room for arch specific syscalls 393 common semget sys_semget 394 common semctl sys_semctlI wonder how you discovered this bug. Did you look up the calling convention on SuperH and compare the argument order for the
sys_sync_file_rangesystem call documented there with the order in the kernel?
Quoted 3 lines
Did you also check what order libc uses? I would expect libc on SuperH misordering the arguments as well unless I am missing something. Or do we know that the code is actually currently broken?
No, there's no reason libc would misorder them because syscalls aren't function calls, and aren't subject to function call ABI. We have to explicitly bind the arguments to registers and make a syscall instruction.
The only reason this bug happened on the kernel side is that someone thought it would be a smart idea to save maybe 10 instructions by treating the register state on entry as directly suitable to jump from asm to a C function rather than explicitly marshalling the arguments out of the user-kernel syscall ABI positions into actual arguments to a C function call.
Rich
Re: [PATCH 10/15] csky, hexagon: fix broken sys_sync_file_range
In reply to Arnd BergmannQuoted 27 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Both of these architectures require u64 function arguments to be passed in even/odd pairs of registers or stack slots, which in case of
sync_file_rangewould result in a seven-argument system call that is not currently possible. The system call is therefore incompatible with all existing binaries.While it would be possible to implement support for seven arguments like on mips, it seems better to use a six-argument version, either with the normal argument order but misaligned as on most architectures or with the reordered
sync_file_range2()calling conventions as on arm and powerpc.Signed-off-by Arnd Bergmann <[email protected]>--- arch/csky/include/uapi/asm/unistd.h | 1 + arch/hexagon/include/uapi/asm/unistd.h | 1 + 2 files changed, 2 insertions(+)arch/csky/include/uapi/asm/unistd.h +0
-0
arch/csky/include/uapi/asm/unistd.h line 9
Quoted 4 lines
arch/csky/include/uapi/asm/unistd.h +1
-0@@ -6,6 +6,7 @@#define __ARCH_WANT_SYS_CLONE3#define __ARCH_WANT_SET_GET_RLIMIT#define __ARCH_WANT_TIME32_SYSCALLS +#define __ARCH_WANT_SYNC_FILE_RANGE2
For csky part.
Quoted 17 lines
arch/csky/include/uapi/asm/unistd.h +0
-0#include <asm-generic/unistd.h> #define __NR_set_thread_area (__NR_arch_specific_syscall + 0)arch/hexagon/include/uapi/asm/unistd.h +1
-1@@ -36,5 +36,6 @@#define __ARCH_WANT_SYS_VFORK#define __ARCH_WANT_SYS_FORK#define __ARCH_WANT_TIME32_SYSCALLS +#define __ARCH_WANT_SYNC_FILE_RANGE2#include <asm-generic/unistd.h> --2.39.2
Signature · 2 lines
Best Regards Guo Ren
Re: [PATCH 08/15] powerpc: restore some missing spu syscalls
In reply to Arnd BergmannQuoted 10 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
A couple of system calls were inadventently removed from the table during a bugfix for 32-bit powerpc entry. Restore the original behavior.
Fixes e23750623835 ("powerpc/32: fix syscall wrappers with 64-bit arguments of unaligned register-pairs")Signed-off-by Arnd Bergmann <[email protected]>--- arch/powerpc/kernel/syscalls/syscall.tbl | 4 ++++ 1 file changed, 4 insertions(+)
cheers
John Paul Adrian Glaubitz
maintainerRe: [PATCH 09/15] sh: rework sync_file_range ABI
In reply to Arnd BergmannHi Arnd,
Quoted 25 lines · Arnd Bergmann
Quoted 6 lines · John Paul Adrian Glaubitz
Quoted 3 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The unusual function calling conventions on superh ended up causing
^^^^^^
It's spelled SuperHFixed now.
Quoted 6 lines
Quoted 6 lines
arch/sh/kernel/sys_sh32.c +0
-0@@ -59,3 +59,14 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, (u64)len0 << 32 | len1, advice);Quoted 8 lines
arch/sh/kernel/sys_sh32.c asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, · line 64
Quoted 5 lines
arch/sh/kernel/sys_sh32.c +3
-0#endif } + +/* +* swap the arguments the way that libc wants it instead of I think "swap the arguments to the order that libc wants them" would be easier to understand here.
Quoted 1 line
Done
Thanks for the two improvements!
Quoted 68 lines
Quoted 11 lines
arch/sh/kernel/syscalls/syscall.tbl line 324
Quoted 10 lines
arch/sh/kernel/syscalls/syscall.tbl +1
-1@@ -321,7 +321,7 @@ 311 common set_robust_list sys_set_robust_list 312 common get_robust_list sys_get_robust_list 313 common splice sys_splice -314 common sync_file_range sys_sync_file_range +314 common sync_file_range sys_sh_sync_file_range6^^^^^^Quoted 1 line
Why the suffix 6 here?
In a later part of my cleanup, I'm consolidating all the copies of this function (arm64, mips, parisc, powerpc, s390, sh, sparc, x86) and picked the name
sys_sync_file_range6()for common implementation.I end up with four entry points here, so the naming is a bit confusing:
-
sys_sync_file_range()is only used on 64-bit architectures, on x32 and on mips-n32. This uses four arguments, including two 64-bit wide ones.-
sys_sync_file_range2()continues to be used on arm, powerpc, xtensa and now on sh, hexagon and csky. I change the implementation to take six 32-bit arguments, but the ABI remains the same as before, with the flags before offset.-
sys_sync_file_range6()is used for most other 32-bit ABIs:
arc, m68k, microblaze, nios2, openrisc, parisc, s390, sh, sparc and x86. This also has six 32-bit arguments but in the default order (fd, offset, nbytes, flags).-
sys_sync_file_range7()is exclusive to mips-o32, this one has an unused argument and is otherwise the same assys_sync_file_range6().My plan is to then have some infrastructure to ensure userspace tools (libc, strace, qemu, rust, ...) use the same calling conventions as the kernel. I'm doing the same thing for all other syscalls that have architecture specific calling conventions, so far I'm using
fadvise64_64_7fanotify_mark6
truncate3
truncate4
ftruncate3
ftruncate4
fallocate6
pread5
pread6
pwrite5
pwrite6
preadv5
preadv6
pwritev5
pwritev6sync_file_range6fadvise64_64_2fadvise64_64_6fadvise64_5fadvise64_6
readahead4
readahead5
Quoted 7 lines
The last number here is usually the number of 32-bit arguments, except for
fadvise64_64_2that uses the same argument reordering trick assync_file_range2.I'm not too happy with the naming but couldn't come up with anything clearer either, so let me know if you have any ideas there.
OK, gotcha. I thought the 6 suffix was for SH only. I'm fine with the naming scheme.
Quoted 24 lines
Quoted 9 lines
Quoted 9 lines
arch/sh/kernel/syscalls/syscall.tbl +1
-0315 common tee sys_tee 316 common vmsplice sys_vmsplice 317 common move_pages sys_move_pages@@ -395,6 +395,7 @@ 385 common pkey_alloc sys_pkey_alloc 386 common pkey_free sys_pkey_free 387 common rseq sys_rseq +388 common sync_file_range2 sys_sync_file_range2 # room for arch specific syscallsQuoted 8 lines
arch/sh/kernel/syscalls/syscall.tbl line 401
Quoted 2 lines
arch/sh/kernel/syscalls/syscall.tbl +0
-0393 common semget sys_semget 394 common semctl sys_semctlI wonder how you discovered this bug. Did you look up the calling convention on SuperH
and compare the argument order for thesys_sync_file_rangesystem call documented there
with the order in the kernel?I had to categorize all architectures based on their calling conventions to see if 64-bit arguments need aligned pairs or not, so I wrote a set of simple C files that I compiled for all architectures to see in which cases they insert unused arguments or swap the order of the upper and lower halves.
Quoted 4 lines
SuperH, parisc and s390 are each slightly different from all the others here, so I ended up reading the ELF psABI docs and/or the compiler sources to be sure.
I also a lot of git history.
Great job, thanks for doing the extra work to verify the ABI.
Quoted 9 lines
Quoted 5 lines
Did you also check what order libc uses? I would expect libc on SuperH misordering the
arguments as well unless I am missing something. Or do we know that the code is actually
currently broken?Yes, I checked glibc, musl and uclibc-ng for all the cases in which the ABI made no sense, as well as to check that my analysis of the kernel sources matches the expectations of the libc.
OK, awesome.
Will you send a v2 so I can ack the updated version of the patch?
I'm also fine with the patch going through your tree, as I would like to start with the changes for v6.11 this week.
Thanks,
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Arnd Bergmann
maintainerRe: [PATCH 14/15] asm-generic: unistd: fix time32 compat syscall handling
In reply to Arnd BergmannQuoted 15 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
arch/riscv/appears to have accidentally enabled the compat time32 syscalls in 64-bit kernels even though the native 32-bit ABI does not expose those.Address this by adding another level of indirection, checking for both the target ABI (32 or 64) and the
__ARCH_WANT_TIME32_SYSCALLSmacro.The macro arguments are meant to follow the syscall.tbl format, the idea here is that by the end of the series, all other syscalls are changed to the same format to make it possible to move all architectures over to generating the system call table consistently.
Only this patch needs to be backported though.
Quoted 3 lines
Cc [email protected] # v5.19+Fixes 7eb6369d7acf ("RISC-V: Add support for rv32 userspace via COMPAT")Signed-off-by Arnd Bergmann <[email protected]>
I had pulled this in from my longer series, but as the kernel build bot reported, this produced build time regressions, so I'll drop it from the v6.10 fixes and will integrated it back as part of the cleanup series.
Arnd
Arnd Bergmann
maintainerRe: [PATCH 09/15] sh: rework sync_file_range ABI
In reply to John Paul Adrian GlaubitzQuoted 12 lines · John Paul Adrian Glaubitz
Quoted 10 lines · Arnd Bergmann
Quoted 5 lines · John Paul Adrian Glaubitz
Did you also check what order libc uses? I would expect libc on SuperH misordering the
arguments as well unless I am missing something. Or do we know that the code is actually
currently broken?Yes, I checked glibc, musl and uclibc-ng for all the cases in which the ABI made no sense, as well as to check that my analysis of the kernel sources matches the expectations of the libc.
Quoted 6 lines
OK, awesome.
Will you send a v2 so I can ack the updated version of the patch?
I'm also fine with the patch going through your tree, as I would like to start with the changes for v6.11 this week.
I should be able to get a v2 out today and apply that to my asm-generic tree to have in linux-next before I send the pull request.
Arnd
Arnd Bergmann
maintainerRe: [PATCH 02/15] syscalls: fix compat_sys_io_pgetevents_time64 usage
In reply to Arnd BergmannQuoted 22 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Using
sys_io_pgetevents()as the entry point for compat mode tasks works almost correctly, but misses the sign extension for themin_nrand nr arguments.This was addressed on parisc by switching to
compat_sys_io_pgetevents_time64()in commit6431e92fc827("parisc:io_pgetevents_time64()needs compat syscall in 32-bit compat mode"), as well as by using more sophisticated system call wrappers on x86 and s390. However, arm64, mips, powerpc, sparc and riscv still have the same bug.Changes all of them over to use
compat_sys_io_pgetevents_time64()like parisc already does. This was clearly the intention when the function was originally added, but it got hooked up incorrectly in the tables.Fixes 48166e6ea47d ("y2038: add 64-bit time_t syscalls to all 32-bitarchitectures")
Signed-off-by Arnd Bergmann <[email protected]>
Quoted 10 lines
--- arch/arm64/include/asm/unistd32.h | 2 +- arch/mips/kernel/syscalls/syscall_n32.tbl | 2 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 2 +- arch/powerpc/kernel/syscalls/syscall.tbl | 2 +- arch/s390/kernel/syscalls/syscall.tbl | 2 +- arch/sparc/kernel/syscalls/syscall.tbl | 2 +- arch/x86/entry/syscalls/syscall_32.tbl | 2 +- include/uapi/asm-generic/unistd.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-)
The build bot reported a randconfig regressions with this patch, which I've now fixed up like this:
kernel/sys_ni.c +1 -1
@@ -46,8 +46,8 @@ COND_SYSCALL(io_getevents_time32);COND_SYSCALL (io_getevents);COND_SYSCALL (io_pgetevents_time32);COND_SYSCALL (io_pgetevents); -COND_SYSCALL_COMPAT (io_pgetevents_time32);COND_SYSCALL_COMPAT (io_pgetevents); +COND_SYSCALL_COMPAT (io_pgetevents_time64);COND_SYSCALL (io_uring_setup);COND_SYSCALL (io_uring_enter);COND_SYSCALL (io_uring_register);
This was already broken on parisc the same way, but the mistake in sys_ni.c turned into a link failure for every compat architecture after my patch.
Arnd