]> www.infradead.org Git - users/dwmw2/linux.git/commit
riscv: entry: always initialize regs->a0 to -ENOSYS
authorCeleste Liu <coelacanthushex@gmail.com>
Thu, 27 Jun 2024 14:23:39 +0000 (22:23 +0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 14 Aug 2024 20:12:22 +0000 (13:12 -0700)
commit61119394631f219e23ce98bcc3eb993a64a8ea64
treeb0b47a1e641edcb5eff2b050813872501dc5b8c9
parentee9a68394b4bea8b9044ec4bfdbaacf45297ecef
riscv: entry: always initialize regs->a0 to -ENOSYS

Otherwise when the tracer changes syscall number to -1, the kernel fails
to initialize a0 with -ENOSYS and subsequently fails to return the error
code of the failed syscall to userspace. For example, it will break
strace syscall tampering.

Fixes: 52449c17bdd1 ("riscv: entry: set a0 = -ENOSYS only when syscall != -1")
Reported-by: "Dmitry V. Levin" <ldv@strace.io>
Reviewed-by: Björn Töpel <bjorn@rivosinc.com>
Cc: stable@vger.kernel.org
Signed-off-by: Celeste Liu <CoelacanthusHex@gmail.com>
Link: https://lore.kernel.org/r/20240627142338.5114-2-CoelacanthusHex@gmail.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/kernel/traps.c