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.
This commit is contained in:
Sönke Holz authored and Sönke Holz committed 2026-06-11 11:39:52 +02:00
1 parent f66d9f8c9c
commit 0b7dc6869e
1 file changed
+1 -1
+1 -1
View File
@@ -68,7 +68,7 @@ static ErrorOr<FlatPtr> 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();