]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/32: fix syscall wrappers with 64-bit arguments of unaligned register-pairs
authorNicholas Piggin <npiggin@gmail.com>
Wed, 12 Oct 2022 03:53:34 +0000 (13:53 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 12 Oct 2022 13:49:58 +0000 (00:49 +1100)
commit27d9dfc8d7615bb8c858749c1a9b358675f95eb4
tree8ee47da57029919434938413c8badf58754fa065
parent01ef022eb0083d27b22a94c6dcbaee61738df492
powerpc/32: fix syscall wrappers with 64-bit arguments of unaligned register-pairs

powerpc 32-bit system call (and function) calling convention for 64-bit
arguments requires the next available odd-pair (two sequential registers
with the first being odd-numbered) from the standard register argument
allocation.

The first argument register is r3, so a 64-bit argument that appears at
an even position in the argument list must skip a register (unless there
were preceding 64-bit arguments, which might throw things off). This
requires non-standard compat definitions to deal with the holes in the
argument register allocation.

With pt_regs syscall wrappers which use a standard mapper to map pt_regs
GPRs to function arguments, 32-bit kernels hit the same basic problem,
the standard definitions don't cope with the unused argument registers.

Fix this by having 32-bit kernels share those syscall definitions with
compat.

Thanks to Jason for spending a lot of time finding and bisecting this
and developing a trivial reproducer. The perfect bug report.

Reported-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Fixes: 653797f9a8485 ("powerpc: Provide syscall wrapper")
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20221012035335.866440-1-npiggin@gmail.com
arch/powerpc/include/asm/syscalls.h
arch/powerpc/kernel/Makefile
arch/powerpc/kernel/sys_ppc32.c
arch/powerpc/kernel/syscalls/syscall.tbl