Commit a3386301 authored by Jinjie Ruan's avatar Jinjie Ruan Committed by Will Deacon
Browse files

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: default avatarKevin Brodsky <kevin.brodsky@arm.com>
Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 741a9000
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -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;
	}