* [PATCH v2] arm64: ptrace: don't warn on missing siginfo in a group-stop
@ 2026-10-23 11:07 Zhao Gongyi
2026-10-23 13:24 ` Oleg Nesterov
0 siblings, 1 reply; 2+ messages in thread
From: Zhao Gongyi @ 2026-10-23 11:07 UTC (permalink / raw)
To: catalin.marinas, will
Cc: mark.rutland, oleg, ruanjinjie, linux-arm-kernel, linux-kernel,
Zhao Gongyi
PTRACE_ATTACH to a group-stopped child can enter do_jobctl_trap(),
which calls ptrace_stop() without siginfo. If the tracer writes
NT_ARM_SYSTEM_CALL, system_call_set() can change syscallno from
NO_SYSCALL before calling update_syscall_orig_x0_after_ptrace(). The
WARN_ON_ONCE(!info) then fires, although this is a valid ptrace stop.
Remove the warning and guard the syscall-exit-stop check against a
missing siginfo. Keep recognizing both SIGTRAP and SIGTRAP | 0x80:
syscall-exit-stops use either value depending on whether the tracer
enabled PTRACE_O_TRACESYSGOOD. With no siginfo, allow the final
assignment to synchronize orig_x0 from x0.
Fixes: 88b839ce497c ("arm64: ptrace: Keep 'orig_x0' in-sync with x0 on syscall entry")
Cc: stable@vger.kernel.org
Signed-off-by: Zhao Gongyi <zhaogongyi@bytedance.com>
---
Changes since v1:
- Remove the warning and early return, as suggested by Oleg.
- Keep recognizing syscall-exit-stops with or without PTRACE_O_TRACESYSGOOD.
v1: https://lore.kernel.org/r/20261016024536.18938-1-zhaogongyi@bytedance.com
Tested on arm64 KVM at af32da41b032 with this v2 applied.
At a group-stop, PTRACE_GETSIGINFO returned -EINVAL and an
NT_ARM_SYSTEM_CALL write succeeded. Syscall-entry and seccomp
x0 rewrites worked. At syscall-exit-stops, NT_PRSTATUS writes succeeded
with and without PTRACE_O_TRACESYSGOOD (si_code 133 and 5,
respectively). No kernel warnings occurred.
arch/arm64/kernel/ptrace.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index f743cbec1..22fb9eeed 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -573,10 +573,6 @@ static void update_syscall_orig_x0_after_ptrace(struct task_struct *target)
if (regs->syscallno == NO_SYSCALL)
return;
- /* We should only be called when target is in a ptrace stop */
- if (WARN_ON_ONCE(!info))
- return;
-
/*
* For compat tasks, orig_r0 is provided directly through GPR index
* 17.
@@ -588,7 +584,7 @@ static void update_syscall_orig_x0_after_ptrace(struct task_struct *target)
* Don't update orig_x0 for a syscall-exit-stop, as x0 now contains the
* return value of the system call.
*/
- if ((info->si_code & ~0x80) == SIGTRAP &&
+ if (info && (info->si_code & ~0x80) == SIGTRAP &&
target->ptrace_message == PTRACE_EVENTMSG_SYSCALL_EXIT) {
return;
}
base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907
--
2.39.5 (Apple Git-154)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] arm64: ptrace: don't warn on missing siginfo in a group-stop
2026-10-23 11:07 [PATCH v2] arm64: ptrace: don't warn on missing siginfo in a group-stop Zhao Gongyi
@ 2026-10-23 13:24 ` Oleg Nesterov
0 siblings, 0 replies; 2+ messages in thread
From: Oleg Nesterov @ 2026-10-23 13:24 UTC (permalink / raw)
To: Zhao Gongyi
Cc: catalin.marinas, will, mark.rutland, ruanjinjie,
linux-arm-kernel, linux-kernel
On 10/23, Zhao Gongyi wrote:
>
> --- a/arch/arm64/kernel/ptrace.c
> +++ b/arch/arm64/kernel/ptrace.c
> @@ -573,10 +573,6 @@ static void update_syscall_orig_x0_after_ptrace(struct task_struct *target)
> if (regs->syscallno == NO_SYSCALL)
> return;
>
> - /* We should only be called when target is in a ptrace stop */
> - if (WARN_ON_ONCE(!info))
> - return;
> -
> /*
> * For compat tasks, orig_r0 is provided directly through GPR index
> * 17.
> @@ -588,7 +584,7 @@ static void update_syscall_orig_x0_after_ptrace(struct task_struct *target)
> * Don't update orig_x0 for a syscall-exit-stop, as x0 now contains the
> * return value of the system call.
> */
> - if ((info->si_code & ~0x80) == SIGTRAP &&
> + if (info && (info->si_code & ~0x80) == SIGTRAP &&
> target->ptrace_message == PTRACE_EVENTMSG_SYSCALL_EXIT) {
> return;
LGTM, but I don't understand this arm-specific code.
And... Do we need to check target->last_siginfo at all?
ptrace_signal() -> ptrace_stop() path sets ->ptrace_message = 0.
In all other cases: if info != NULL, then .si_code == target->exit_code.
ptrace_event(event) users always use event != 0 and != 0x80.
So it seems that we can just do
if ((target->exit_code & ~0x80) == SIGTRAP &&
target->ptrace_message == PTRACE_EVENTMSG_SYSCALL_EXIT)
?
I'll recheck... If I am right, perhaps it makes sense to simplify
ptrace_get_syscall_info_op().
Anyway, up to you.
Oleg.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-23 13:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-23 11:07 [PATCH v2] arm64: ptrace: don't warn on missing siginfo in a group-stop Zhao Gongyi
2026-10-23 13:24 ` Oleg Nesterov
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®