arm64/ptrace: Return early for ptrace_report_syscall_entry() error

The generic entry abort the syscall_trace_enter() sequence if
ptrace_report_syscall_entry() errors out, but arm64 not.

When ptrace requests interception, it should prevent all subsequent
system-call processing, including audit and seccomp. In preparation for
moving arm64 over to the generic entry code, return early if
ptrace_report_syscall_entry() encounters an error.

Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: Will Deacon <will@kernel.org>
This commit is contained in:
Jinjie Ruan 2025-12-22 19:47:24 +08:00 committed by Will Deacon
parent 741a900017
commit a338630166

View File

@ -2372,15 +2372,18 @@ static __always_inline unsigned long ptrace_save_reg(struct pt_regs *regs,
return saved_reg;
}
static void report_syscall_entry(struct pt_regs *regs)
static int report_syscall_entry(struct pt_regs *regs)
{
unsigned long saved_reg;
int regno;
int regno, ret;
saved_reg = ptrace_save_reg(regs, PTRACE_SYSCALL_ENTER, &regno);
if (ptrace_report_syscall_entry(regs))
ret = ptrace_report_syscall_entry(regs);
if (ret)
forget_syscall(regs);
regs->regs[regno] = saved_reg;
return ret;
}
static void report_syscall_exit(struct pt_regs *regs)
@ -2407,10 +2410,11 @@ static void report_syscall_exit(struct pt_regs *regs)
int syscall_trace_enter(struct pt_regs *regs)
{
unsigned long flags = read_thread_flags();
int ret;
if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) {
report_syscall_entry(regs);
if (flags & _TIF_SYSCALL_EMU)
ret = report_syscall_entry(regs);
if (ret || (flags & _TIF_SYSCALL_EMU))
return NO_SYSCALL;
}