From: Matt Turner <mattst88@gmail.com>
To: stable@vger.kernel.org,
Richard Henderson <richard.henderson@linaro.org>,
Magnus Lindholm <linmag7@gmail.com>
Cc: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org,
Matt Turner <mattst88@gmail.com>
Subject: [PATCH 7.1.y 7.2.y 7.3.y] alpha: honor force_successful_syscall_return() again
Date: Thu, 05 Nov 2026 18:39:32 -0500 [thread overview]
Message-ID: <20261105-alpha-force-success-fix-v1-1-8c26d60c5fff@gmail.com> (raw)
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>
next reply other threads:[~2026-11-05 23:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 23:39 Matt Turner [this message]
2026-11-06 12:12 ` Magnus Lindholm
2026-11-06 16:35 ` Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261105-alpha-force-success-fix-v1-1-8c26d60c5fff@gmail.com \
--to=mattst88@gmail.com \
--cc=linmag7@gmail.com \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=richard.henderson@linaro.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®