* [PATCH] MIPS: ptrace: Fix syscall skipping via PTRACE_SYSCALL
@ 2026-07-17 11:27 Thomas Bogendoerfer
2026-07-18 15:23 ` Oleg Nesterov
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Bogendoerfer @ 2026-07-17 11:27 UTC (permalink / raw)
To: Oleg Nesterov, James Hogan, Kees Cook, linux-mips, linux-kernel
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@alpha.franken.de>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] MIPS: ptrace: Fix syscall skipping via PTRACE_SYSCALL
2026-07-17 11:27 [PATCH] MIPS: ptrace: Fix syscall skipping via PTRACE_SYSCALL Thomas Bogendoerfer
@ 2026-07-18 15:23 ` Oleg Nesterov
0 siblings, 0 replies; 2+ messages in thread
From: Oleg Nesterov @ 2026-07-18 15:23 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: James Hogan, Kees Cook, linux-mips, linux-kernel
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@alpha.franken.de>
> ---
> 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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-18 15:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-17 11:27 [PATCH] MIPS: ptrace: Fix syscall skipping via PTRACE_SYSCALL Thomas Bogendoerfer
2026-07-18 15:23 ` Oleg Nesterov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.