Re: [PATCH] s390/syscall: Set -ENOSYS return value before calling syscall_enter_from_user_mode_work()
From: Alexander Gordeev
Date: Thu Nov 05 2026 - 12:02:42 EST
On Wed, Oct 21, 2026 at 10:56:43AM +0200, Heiko Carstens wrote:
> On s390 gpr2 contains both the system call return value and the system call
> number. With [1] it is expected to set gpr2 to -ENOSYS before calling
> syscall_enter_from_user_mode_work(), so that a skipped system call has a
> defined default return value, and not the system call number like today.
>
> To make that work and stay compatible with existing ptrace users, replace
> PIF_SYSCALL_RET_SET with PIF_SYSCALL_ENTRY. PIF_SYSCALL_ENTRY is set before
> syscall_enter_from_user_mode_work() is called and indicates that reads and
> writes to gpr2 via PTRACE_PEEKUSR, PTRACE_POKEUSR, PTRACE_GETREGSET, and
> PTRACE_SETREGSET are redirected to regs->int_code, which contains the
> system call number. gpr2, which contains the system call return value, can
> only be changed via syscall_set_return_value() (e.g. seccomp).
>
> After syscall_enter_from_user_mode_work() returns, PIF_SYSCALL_ENTRY is
> cleared and the code behaves as before.
>
> PIF_SYSCALL_RET_SET was introduced with [2]. The flag was set by
> syscall_set_return_value() and allowed seccomp to skip syscalls
> and inject a return value despite the gpr2 aliasing.
>
> Kernel seccomp and ptrace selftests, as well as strace selftests, show no
> difference with and without this change.
>
> [1] 05c033db7e9a ("entry, treewide: Make syscall_enter_from_user_mode[_work]() indicate syscall execution")
> [2] 56e62a737028 ("s390: convert to generic entry")
>
> Fixes: 05c033db7e9a ("entry, treewide: Make syscall_enter_from_user_mode[_work]() indicate syscall execution")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
> ---
> arch/s390/include/asm/ptrace.h | 4 ++--
> arch/s390/include/asm/syscall.h | 1 -
> arch/s390/kernel/ptrace.c | 28 +++++++++++++++++++++++-----
> arch/s390/kernel/syscall.c | 19 +++++++++----------
> 4 files changed, 34 insertions(+), 18 deletions(-)
Acked-by: Alexander Gordeev <agordeev@xxxxxxxxxxxxx>