From 548488f050924f2e07f848b9e00a6c63a1084eb6 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Mon, 6 Dec 2021 19:33:19 +0200 Subject: [PATCH] Kernel: Terminate current thread immediately on unhandled urgent signal If we're sending an urgent signal (i.e. due to unexpected conditions) and the Process did not setup any signal handler, we should immediately terminate the Thread, to ensure the current trap frame is preserved for the impending core dump. --- Kernel/Thread.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 5c0867befe..5a263a1835 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -701,6 +701,10 @@ void Thread::send_urgent_signal_to_self(u8 signal) SpinlockLocker lock(g_scheduler_lock); result = dispatch_signal(signal); } + if (result == DispatchSignalResult::Terminate) { + Thread::current()->die_if_needed(); + VERIFY_NOT_REACHED(); // dispatch_signal will request termination of the thread, so the above call should never return + } if (result == DispatchSignalResult::Yield) yield_and_release_relock_big_lock(); }