]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
arm64/ptrace: Return early for ptrace_report_syscall_entry() error
authorJinjie Ruan <ruanjinjie@huawei.com>
Mon, 22 Dec 2025 11:47:24 +0000 (19:47 +0800)
committerWill Deacon <will@kernel.org>
Tue, 27 Jan 2026 10:38:36 +0000 (10:38 +0000)
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>
arch/arm64/kernel/ptrace.c

index 03fe2f8a4d5400ff7a6b95eb11b23b86a53cef7b..f333791ffba6d7ffa5ec29bf786e1de85d9975ed 100644 (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;
        }