[PATCH v18 02/14] arm64: ptrace: Rework audit_syscall_entry()
From: Jinjie Ruan <hidden>
Date: 2026-09-02 09:55:21
Also in:
lkml
Subsystem:
arm64 port (aarch64 architecture), ptrace support, the rest · Maintainers:
Catalin Marinas, Will Deacon, Oleg Nesterov, Linus Torvalds
Extract syscall_enter_audit() helper and switch to generic helpers to get syscall number and syscall arguments, matching the generic entry implementation. The new code: - Checks audit_context() first to avoid unnecessary work when audit is not active. - Use syscall_get_arguments() helper instead of directly accessing regs fields. - Use syscall_get_nr() helper to get syscall number instead of directly accessing regs->syscallno. - Now exactly equivalent to generic entry's syscall_enter_audit(). This is a preparation step for converting arm64 to the generic entry infrastructure. No functional changes intended. Cc: Mark Rutland <mark.rutland@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Ada Couprie Diaz <redacted> Reviewed-by: Linus Walleij <linusw@kernel.org> Reviewed-by: Yeoreum Yun <redacted> Reviewed-by: Kevin Brodsky <redacted> Signed-off-by: Jinjie Ruan <redacted> --- arch/arm64/kernel/ptrace.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 96462de75d4b..ede6f3bf29e0 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c@@ -2458,6 +2458,17 @@ static void report_syscall_exit(struct pt_regs *regs) } } +#ifdef CONFIG_AUDITSYSCALL +static inline void syscall_enter_audit(struct pt_regs *regs) +{ + long syscall = syscall_get_nr(current, regs); + unsigned long args[6]; + + syscall_get_arguments(current, regs, args); + __audit_syscall_entry(syscall, args[0], args[1], args[2], args[3]); +} +#endif + int syscall_trace_enter(struct pt_regs *regs) { unsigned long flags = read_thread_flags();
@@ -2476,8 +2487,8 @@ int syscall_trace_enter(struct pt_regs *regs) if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) trace_sys_enter(regs, regs->syscallno); - audit_syscall_entry(regs->syscallno, regs->orig_x0, regs->regs[1], - regs->regs[2], regs->regs[3]); + if (unlikely(audit_context())) + syscall_enter_audit(regs); return regs->syscallno; }
--
2.34.1