[PATCH v17 03/15] arm64: ptrace: Open-code seccomp check in syscall_trace_enter()
From: Jinjie Ruan
Date: Tue Jul 21 2026 - 04:23:24 EST
Refactor syscall_trace_enter() by open-coding the seccomp check to
align with the generic entry framework.
The generic entry implementation expands the seccomp check in-place
by testing SYSCALL_WORK_SECCOMP and directly calling the underlying
__seccomp_permit_syscall() function. Moreover, generic entry explicitly
re-reads work flags after ptrace handling to ensure any updates to
seccomp work flags during the ptrace stop are observed.
Bring arm64 in line with this behavior:
- Re-read thread flags after ptrace handling.
- Test the updated flags for _TIF_SECCOMP and call
__seccomp_permit_syscall().
No functional changes are intended; this change simplifies future
migration to the generic entry framework.
Cc: Mark Rutland <mark.rutland@xxxxxxx>
Cc: Will Deacon <will@xxxxxxxxxx>
Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
Link: https://lore.kernel.org/all/20260713025712.416366-1-ruanjinjie@xxxxxxxxxx/
Reviewed-by: Ada Couprie Diaz <ada.coupriediaz@xxxxxxx>
Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>
Reviewed-by: Yeoreum Yun <yeoreum.yun@xxxxxxx>
Reviewed-by: Kevin Brodsky <kevin.brodsky@xxxxxxx>
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
---
arch/arm64/kernel/ptrace.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 643e63a65734..cd0607ec70ef 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -2478,11 +2478,16 @@ int syscall_trace_enter(struct pt_regs *regs)
ret = report_syscall_entry(regs);
if (ret || (flags & _TIF_SYSCALL_EMU))
return NO_SYSCALL;
+
+ /* ptrace might have changed thread flags */
+ flags = read_thread_flags();
}
/* Do the secure computing after ptrace; failures should be fast. */
- if (!seccomp_permit_syscall())
- return NO_SYSCALL;
+ if (unlikely(flags & _TIF_SECCOMP)) {
+ if (!__seccomp_permit_syscall())
+ return NO_SYSCALL;
+ }
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
trace_sys_enter(regs, regs->syscallno);
--
2.34.1