Message ID | 87mt9cxd6g.fsf_-_@igel.home (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | powerpc/32: fix syscall wrappers with 64-bit arguments | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/github-powerpc_selftests | success | Successfully ran 10 jobs. |
snowpatch_ozlabs/github-powerpc_ppctests | success | Successfully ran 10 jobs. |
snowpatch_ozlabs/github-powerpc_clang | success | Successfully ran 6 jobs. |
snowpatch_ozlabs/github-powerpc_sparse | success | Successfully ran 4 jobs. |
snowpatch_ozlabs/github-powerpc_kernel_qemu | success | Successfully ran 23 jobs. |
On Mon, Oct 31, 2022, at 15:47, Andreas Schwab wrote: > With the introducion of syscall wrappers all wrappers for syscalls with > 64-bit arguments must be handled specially, not only those that have > unaligned 64-bit arguments. This left out the fallocate and > sync_file_range2 syscalls. > > Fixes: 7e92e01b7245 ("powerpc: Provide syscall wrapper") > Fixes: e23750623835 ("powerpc/32: fix syscall wrappers with 64-bit > arguments of unaligned register-pairs") > Signed-off-by: Andreas Schwab <schwab@linux-m68k.org> This looks correct as a minmal bugfix to be backported. I have cross-checked the syscalls with 64-bit arguments that have special handlers on powerpc against the list from x86 to make sure there are no other obvious ones that need a similar fix. Reviewed-by: Arnd Bergmann <arnd@arndb.de> > + > +#ifdef CONFIG_PPC32 > +SYSCALL_DEFINE6(ppc_fallocate, > + int, fd, int, mode, > + u32, offset1, u32, offset2, u32, len1, u32, len2) > +{ > + return ksys_fallocate(fd, mode, > + merge_64(offset1, offset2), > + merge_64(len1, len2)); > +} > +#endif This is identical to compat_sys_fallocate() and to (an andian-corrected) sys_ia32_fallocate(), right? I still think we should eventually generalize this further and make all these handlers architecture independent to prevent the same bug from happening on additional architectures, but that should probably be done separately. Arnd
On Mon, 31 Oct 2022 15:47:35 +0100, Andreas Schwab wrote: > With the introducion of syscall wrappers all wrappers for syscalls with > 64-bit arguments must be handled specially, not only those that have > unaligned 64-bit arguments. This left out the fallocate and > sync_file_range2 syscalls. > > Applied to powerpc/fixes. [1/1] powerpc/32: fix syscall wrappers with 64-bit arguments https://git.kernel.org/powerpc/c/ce883a2ba310cd7c291bb66ce5d207965fca6003 cheers
diff --git a/arch/powerpc/include/asm/syscalls.h b/arch/powerpc/include/asm/syscalls.h index a1142496cd58..6d51b007b59e 100644 --- a/arch/powerpc/include/asm/syscalls.h +++ b/arch/powerpc/include/asm/syscalls.h @@ -104,6 +104,13 @@ long sys_ppc_ftruncate64(unsigned int fd, u32 reg4, unsigned long len1, unsigned long len2); long sys_ppc32_fadvise64(int fd, u32 unused, u32 offset1, u32 offset2, size_t len, int advice); +long sys_ppc_sync_file_range2(int fd, unsigned int flags, + unsigned int offset1, + unsigned int offset2, + unsigned int nbytes1, + unsigned int nbytes2); +long sys_ppc_fallocate(int fd, int mode, u32 offset1, u32 offset2, + u32 len1, u32 len2); #endif #ifdef CONFIG_COMPAT long compat_sys_mmap2(unsigned long addr, size_t len, diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c index 1ab4a4d95aba..d451a8229223 100644 --- a/arch/powerpc/kernel/sys_ppc32.c +++ b/arch/powerpc/kernel/sys_ppc32.c @@ -112,7 +112,7 @@ PPC32_SYSCALL_DEFINE6(ppc32_fadvise64, advice); } -COMPAT_SYSCALL_DEFINE6(ppc_sync_file_range2, +PPC32_SYSCALL_DEFINE6(ppc_sync_file_range2, int, fd, unsigned int, flags, unsigned int, offset1, unsigned int, offset2, unsigned int, nbytes1, unsigned int, nbytes2) @@ -122,3 +122,14 @@ COMPAT_SYSCALL_DEFINE6(ppc_sync_file_range2, return ksys_sync_file_range(fd, offset, nbytes, flags); } + +#ifdef CONFIG_PPC32 +SYSCALL_DEFINE6(ppc_fallocate, + int, fd, int, mode, + u32, offset1, u32, offset2, u32, len1, u32, len2) +{ + return ksys_fallocate(fd, mode, + merge_64(offset1, offset2), + merge_64(len1, len2)); +} +#endif diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl index e9e0df4f9a61..a0be127475b1 100644 --- a/arch/powerpc/kernel/syscalls/syscall.tbl +++ b/arch/powerpc/kernel/syscalls/syscall.tbl @@ -394,8 +394,11 @@ 305 common signalfd sys_signalfd compat_sys_signalfd 306 common timerfd_create sys_timerfd_create 307 common eventfd sys_eventfd -308 common sync_file_range2 sys_sync_file_range2 compat_sys_ppc_sync_file_range2 -309 nospu fallocate sys_fallocate compat_sys_fallocate +308 32 sync_file_range2 sys_ppc_sync_file_range2 compat_sys_ppc_sync_file_range2 +308 64 sync_file_range2 sys_sync_file_range2 +308 spu sync_file_range2 sys_sync_file_range2 +309 32 fallocate sys_ppc_fallocate compat_sys_fallocate +309 64 fallocate sys_fallocate 310 nospu subpage_prot sys_subpage_prot 311 32 timerfd_settime sys_timerfd_settime32 311 64 timerfd_settime sys_timerfd_settime
With the introducion of syscall wrappers all wrappers for syscalls with 64-bit arguments must be handled specially, not only those that have unaligned 64-bit arguments. This left out the fallocate and sync_file_range2 syscalls. Fixes: 7e92e01b7245 ("powerpc: Provide syscall wrapper") Fixes: e23750623835 ("powerpc/32: fix syscall wrappers with 64-bit arguments of unaligned register-pairs") Signed-off-by: Andreas Schwab <schwab@linux-m68k.org> --- arch/powerpc/include/asm/syscalls.h | 7 +++++++ arch/powerpc/kernel/sys_ppc32.c | 13 ++++++++++++- arch/powerpc/kernel/syscalls/syscall.tbl | 7 +++++-- 3 files changed, 24 insertions(+), 3 deletions(-)