diff options
author | Andreas Kling <kling@serenityos.org> | 2021-02-19 12:10:29 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-19 12:13:54 +0100 |
commit | 6e83be67b8ccb8edfa1cd6617ea37ca36960b567 (patch) | |
tree | 3a026e698e671c8f8ff6f26c15f38258569e52d8 | |
parent | 37d8faf1b45a88ca195175f63a2bad374fca3e6e (diff) | |
download | serenity-6e83be67b8ccb8edfa1cd6617ea37ca36960b567.zip |
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.
-rw-r--r-- | Kernel/Syscalls/execve.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index 96787e5979..4925be50a1 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -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. |