From 0b7dc6869ea789d46b5ac48fa5f0aeefef763b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Holz?= Date: Sat, 30 May 2026 21:04:03 +0200 Subject: [PATCH] Kernel: Only allow tracing stopped threads Previously, this allowed tracing Runnable threads (or threads in any other state other than Running). Allowing threads to be traced while they are runnable doesn't seem like a good idea, especially since they can be scheduled while the tracer thread is still in the ptrace() syscall. Other Unixes seem to only allow tracing stopped threads as well. --- Kernel/Syscalls/ptrace.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/Syscalls/ptrace.cpp b/Kernel/Syscalls/ptrace.cpp index 85ebc205932..ecf97dd7416 100644 --- a/Kernel/Syscalls/ptrace.cpp +++ b/Kernel/Syscalls/ptrace.cpp @@ -68,7 +68,7 @@ static ErrorOr handle_ptrace(Kernel::Syscall::SC_ptrace_params const& p if (tracer->tracer_pid() != caller.pid()) return EBUSY; - if (peer->state() == Thread::State::Running) + if (peer->state() != Thread::State::Stopped) return EBUSY; scheduler_lock.unlock();