From 39ecb832e476a3695ca14cb3fb8e9447e501d775 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Mon, 6 Dec 2021 19:57:25 +0200 Subject: [PATCH] Kernel: Don't try to dispatch urgent signals for kernel crashes If we crashed in the kernel there's no point to sending a signal to the active process, we're going to panic soon anyway. --- Kernel/Arch/x86/common/Interrupts.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel/Arch/x86/common/Interrupts.cpp b/Kernel/Arch/x86/common/Interrupts.cpp index 5cedb48388..5ad4f58bbd 100644 --- a/Kernel/Arch/x86/common/Interrupts.cpp +++ b/Kernel/Arch/x86/common/Interrupts.cpp @@ -219,7 +219,8 @@ void handle_crash(RegisterState const& regs, char const* description, int signal if (!current_thread) PANIC("{} with !Thread::current()", description); - if (!current_thread->should_ignore_signal(signal) && !current_thread->is_signal_masked(signal)) { + auto crashed_in_kernel = (regs.cs & 3) == 0; + if (!crashed_in_kernel && !current_thread->should_ignore_signal(signal) && !current_thread->is_signal_masked(signal)) { current_thread->send_urgent_signal_to_self(signal); return; } @@ -233,9 +234,8 @@ void handle_crash(RegisterState const& regs, char const* description, int signal dmesgln("CRASH: CPU #{} {} in ring {}", Processor::current_id(), description, (regs.cs & 3)); dump(regs); - if (!(regs.cs & 3)) { + if (crashed_in_kernel) PANIC("Crash in ring 0"); - } process.crash(signal, regs.ip(), out_of_memory); }