mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 7.1.y 7.2.y 7.3.y] alpha: honor force_successful_syscall_return() again
@ 2026-11-05 23:39 Matt Turner
  2026-11-06 12:12 ` Magnus Lindholm
  2026-11-06 16:35 ` Sasha Levin
  0 siblings, 2 replies; 3+ messages in thread
From: Matt Turner @ 2026-11-05 23:39 UTC (permalink / raw)
  To: stable, Richard Henderson, Magnus Lindholm
  Cc: linux-alpha, linux-kernel, Matt Turner

This fix is for 7.1.y, 7.2.y and 7.3.y only.  Mainline is not affected
since commit 83bd31c2840b ("alpha: enable GENERIC_ENTRY") in v7.4-rc1,
which replaced the saved-r0 check with a flag in thread_info.  That
conversion is far too large for stable, so this patch fixes the old
entry code instead.

Syscalls that return data rather than a status, such as PTRACE_PEEKUSR,
PTRACE_PEEKTEXT/PEEKDATA, osf_sigprocmask and shmat, call
force_successful_syscall_return() so that a result with the top bit set
is not mistaken for an error.  On alpha that clears the saved r0, and
$syscall_error and $strace_error used to check for this and take the
success path.

Commit 55b22075f784 ("alpha: add support for SECCOMP and
SECCOMP_FILTER") moved the restart syscall number to r2 and dropped both
checks, so any negative result now comes back to userspace as an
error with a3 set.  PTRACE_PEEKUSR of a register holding -1 fails with
EPERM, which makes sandbox abort when it traces static binaries during
Gentoo package builds, and PTRACE_PEEKUSR of a register holding
0xffffffffffffe000 fails with errno 8192, which breaks unwinding of a
ptrace-stopped thread in elfutils (run-backtrace-native.sh).

Restore the checks on both exit paths.  On the traced path the success
path also has to stop falling through into
SYSCALL_SKIP_RETURN_RESTART_GATE, which is meant for skipped syscalls
and would turn a forced-success result of -1 into ENOSYS.

Link: https://bugs.gentoo.org/985765
Fixes: 55b22075f784 ("alpha: add support for SECCOMP and SECCOMP_FILTER")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
This is a stable-only fix for 7.1.y, 7.2.y and 7.3.y; it applies to all
three (with a 16-line offset on 7.1.y and 7.2.y).  Mainline fixed the
same problem differently by switching alpha to GENERIC_ENTRY in v7.4-rc1,
which is too large to backport.
---
 arch/alpha/kernel/entry.S | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
index 9f2608de2544..fe88cd598492 100644
--- a/arch/alpha/kernel/entry.S
+++ b/arch/alpha/kernel/entry.S
@@ -603,6 +603,14 @@ ret_to_kernel:
 
 	.align 3
 $syscall_error:
+	/*
+	 * force_successful_syscall_return() zeroes the saved r0 (the
+	 * syscall number): the negative return value is data, not an
+	 * error number.
+	 */
+	ldq	$18, 0($sp)
+	beq	$18, $ret_success
+
         /* Restart syscall nr comes from saved r2 (preserved even if r0 overwritten). */
 	ldq	$18, 16($sp)	/* old syscall nr for restart */
 
@@ -700,9 +708,11 @@ ret_from_straced:
 $strace_success:
 	stq	$31, 72($sp)		/* a3=0 => no error */
 	stq	$0, 0($sp)		/* save return value */
+	br	$strace_leave
 
 $strace_skip_call:
 	SYSCALL_SKIP_RETURN_RESTART_GATE
+$strace_leave:
 	DO_SWITCH_STACK
 	jsr	$26, syscall_trace_leave
 	UNDO_SWITCH_STACK
@@ -710,6 +720,10 @@ $strace_skip_call:
 
 	.align	3
 $strace_error:
+	/* See $syscall_error. */
+	ldq	$18, 0($sp)
+	beq	$18, $strace_success
+
 	ldq	$18, 16($sp)	/* restart syscall nr */
 	ldq	$19, 72($sp)	/* .. and this a3 */
 

---
base-commit: f2c53ea949c5048f96b3dbb5a5ee7131ce4ff2de
change-id: 20261105-alpha-force-success-fix-6df76c50033a

Best regards,
--  
Matt Turner <mattst88@gmail.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 7.1.y 7.2.y 7.3.y] alpha: honor force_successful_syscall_return() again
  2026-11-05 23:39 [PATCH 7.1.y 7.2.y 7.3.y] alpha: honor force_successful_syscall_return() again Matt Turner
@ 2026-11-06 12:12 ` Magnus Lindholm
  2026-11-06 16:35 ` Sasha Levin
  1 sibling, 0 replies; 3+ messages in thread
From: Magnus Lindholm @ 2026-11-06 12:12 UTC (permalink / raw)
  To: Matt Turner; +Cc: stable, Richard Henderson, linux-alpha, linux-kernel

Hi Matt,

On Fri, Nov 6, 2026 at 12:39 AM Matt Turner <mattst88@gmail.com> wrote:
>
> This fix is for 7.1.y, 7.2.y and 7.3.y only.  Mainline is not affected
> since commit 83bd31c2840b ("alpha: enable GENERIC_ENTRY") in v7.4-rc1,
> which replaced the saved-r0 check with a flag in thread_info.  That
> conversion is far too large for stable, so this patch fixes the old
> entry code instead.
>
> Syscalls that return data rather than a status, such as PTRACE_PEEKUSR,
> PTRACE_PEEKTEXT/PEEKDATA, osf_sigprocmask and shmat, call
> force_successful_syscall_return() so that a result with the top bit set
> is not mistaken for an error.  On alpha that clears the saved r0, and
> $syscall_error and $strace_error used to check for this and take the
> success path.
>
> Commit 55b22075f784 ("alpha: add support for SECCOMP and
> SECCOMP_FILTER") moved the restart syscall number to r2 and dropped both
> checks, so any negative result now comes back to userspace as an
> error with a3 set.  PTRACE_PEEKUSR of a register holding -1 fails with
> EPERM, which makes sandbox abort when it traces static binaries during
> Gentoo package builds, and PTRACE_PEEKUSR of a register holding
> 0xffffffffffffe000 fails with errno 8192, which breaks unwinding of a
> ptrace-stopped thread in elfutils (run-backtrace-native.sh).
>
> Restore the checks on both exit paths.  On the traced path the success
> path also has to stop falling through into
> SYSCALL_SKIP_RETURN_RESTART_GATE, which is meant for skipped syscalls
> and would turn a forced-success result of -1 into ENOSYS.
>
> Link: https://bugs.gentoo.org/985765
> Fixes: 55b22075f784 ("alpha: add support for SECCOMP and SECCOMP_FILTER")
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Matt Turner <mattst88@gmail.com>
> ---
> This is a stable-only fix for 7.1.y, 7.2.y and 7.3.y; it applies to all
> three (with a 16-line offset on 7.1.y and 7.2.y).  Mainline fixed the
> same problem differently by switching alpha to GENERIC_ENTRY in v7.4-rc1,
> which is too large to backport.
> ---
>  arch/alpha/kernel/entry.S | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
> index 9f2608de2544..fe88cd598492 100644
> --- a/arch/alpha/kernel/entry.S
> +++ b/arch/alpha/kernel/entry.S
> @@ -603,6 +603,14 @@ ret_to_kernel:
>
>         .align 3
>  $syscall_error:
> +       /*
> +        * force_successful_syscall_return() zeroes the saved r0 (the
> +        * syscall number): the negative return value is data, not an
> +        * error number.
> +        */
> +       ldq     $18, 0($sp)
> +       beq     $18, $ret_success
> +
>          /* Restart syscall nr comes from saved r2 (preserved even if r0 overwritten). */
>         ldq     $18, 16($sp)    /* old syscall nr for restart */
>
> @@ -700,9 +708,11 @@ ret_from_straced:
>  $strace_success:
>         stq     $31, 72($sp)            /* a3=0 => no error */
>         stq     $0, 0($sp)              /* save return value */
> +       br      $strace_leave
>
>  $strace_skip_call:
>         SYSCALL_SKIP_RETURN_RESTART_GATE
> +$strace_leave:
>         DO_SWITCH_STACK
>         jsr     $26, syscall_trace_leave
>         UNDO_SWITCH_STACK
> @@ -710,6 +720,10 @@ $strace_skip_call:
>
>         .align  3
>  $strace_error:
> +       /* See $syscall_error. */
> +       ldq     $18, 0($sp)
> +       beq     $18, $strace_success
> +
>         ldq     $18, 16($sp)    /* restart syscall nr */
>         ldq     $19, 72($sp)    /* .. and this a3 */
>
>
> ---
> base-commit: f2c53ea949c5048f96b3dbb5a5ee7131ce4ff2de
> change-id: 20261105-alpha-force-success-fix-6df76c50033a
>
> Best regards,
> --
> Matt Turner <mattst88@gmail.com>
>

Built and boot-tested on v7.1, v7.2 and v7.3 using Alpha QEMU
with stock Clipper PALcode, with one and four CPUs.

All 56 raw r0/a3 checks passed with the patch, covering traced
and untraced ptrace PEEK returns, including -1 and -8192,
other forced-success returns, and normal success/error cases.
Unpatched controls reproduced 32 failures on each release.

Tested-by: Magnus Lindholm <linmag7@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 7.1.y 7.2.y 7.3.y] alpha: honor force_successful_syscall_return() again
  2026-11-05 23:39 [PATCH 7.1.y 7.2.y 7.3.y] alpha: honor force_successful_syscall_return() again Matt Turner
  2026-11-06 12:12 ` Magnus Lindholm
@ 2026-11-06 16:35 ` Sasha Levin
  1 sibling, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2026-11-06 16:35 UTC (permalink / raw)
  To: stable, Richard Henderson, Magnus Lindholm
  Cc: Sasha Levin, linux-alpha, linux-kernel, Matt Turner

> This fix is for 7.1.y, 7.2.y and 7.3.y only.

Queued for 7.3, thanks.

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-06 16:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-05 23:39 [PATCH 7.1.y 7.2.y 7.3.y] alpha: honor force_successful_syscall_return() again Matt Turner
2026-11-06 12:12 ` Magnus Lindholm
2026-11-06 16:35 ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®