Re: [PATCH] MIPS: ptrace: Fix syscall skipping via PTRACE_SYSCALL

From: Oleg Nesterov

Date: Sat Jul 18 2026 - 11:23:54 EST


I obviously can't ack the mips-specific change, but it looks good to me.

Thomas, thanks again.

Oleg.

On 07/17, Thomas Bogendoerfer wrote:
>
> If tracer wanted to skip a syscall return value was always
> overwritten with -ENOSYS. Fix this by checking against original
> syscall number and only return -ENOSYS, if it is negative.
>
> Fixes: b6318a903d06 ("MIPS/ptrace: Pick up ptrace/seccomp changed syscalls")
> Signed-off-by: Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>
> ---
> arch/mips/kernel/ptrace.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
> index 3f4c94c88124..87102a03b6ea 100644
> --- a/arch/mips/kernel/ptrace.c
> +++ b/arch/mips/kernel/ptrace.c
> @@ -1321,8 +1321,12 @@ long arch_ptrace(struct task_struct *child, long request,
> */
> asmlinkage long syscall_trace_enter(struct pt_regs *regs)
> {
> + long syscall;
> +
> user_exit();
>
> + syscall = current_thread_info()->syscall;
> +
> if (test_thread_flag(TIF_SYSCALL_TRACE)) {
> if (ptrace_report_syscall_entry(regs))
> return -1;
> @@ -1342,7 +1346,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs)
> * Negative syscall numbers are mistaken for rejected syscalls, but
> * won't have had the return value set appropriately, so we do so now.
> */
> - if (current_thread_info()->syscall < 0)
> + if (syscall < 0)
> syscall_set_return_value(current, regs, -ENOSYS, 0);
> return current_thread_info()->syscall;
> }
> --
> 2.51.0
>