From 6e83be67b8ccb8edfa1cd6617ea37ca36960b567 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 19 Feb 2021 12:10:29 +0100 Subject: 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. --- Kernel/Syscalls/execve.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 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. -- cgit v1.2.3