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 Cc: Will Deacon Cc: Catalin Marinas Link: https://lore.kernel.org/all/20260713025712.416366-1-ruanjinjie@huawei.com/ Reviewed-by: Ada Couprie Diaz Reviewed-by: Linus Walleij Reviewed-by: Yeoreum Yun Reviewed-by: Kevin Brodsky Signed-off-by: Jinjie Ruan --- 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