Kernel: Release ptrace lock in exec before stopping due to PT_TRACE_ME

If we have a tracer process waiting for us to exec, we need to release
the ptrace lock before stopping ourselves, since otherwise the tracer
will block forever on the lock.

Fixes #5409.
This commit is contained in:
Andreas Kling 2021-02-19 12:10:29 +01:00
parent 37d8faf1b4
commit 6e83be67b8
Notes: sideshowbarker 2024-07-18 22:09:16 +09:00

View File

@ -584,8 +584,11 @@ KResult Process::do_exec(NonnullRefPtr<FileDescription> main_program_description
return make_stack_result.error();
u32 new_userspace_esp = make_stack_result.value();
if (wait_for_tracer_at_next_execve())
if (wait_for_tracer_at_next_execve()) {
// Make sure we release the ptrace lock here or the tracer will block forever.
ptrace_locker.unlock();
Thread::current()->send_urgent_signal_to_self(SIGSTOP);
}
// We enter a critical section here because we don't want to get interrupted between do_exec()
// and Processor::assume_context() or the next context switch.