From fb2be937ac0fb34b04733f26cd8494e1569669ee Mon Sep 17 00:00:00 2001 From: yyny <6576327+yyny@users.noreply.github.com> Date: Mon, 19 Dec 2022 21:27:58 +0100 Subject: [PATCH] Kernel: Allow sending `SIGCONT` to processes in the same group Allow sending `SIGCONT` to processes that share the same `pgid`. This is allowed in Linux aswell. Also fixes a FIXME :^) --- Kernel/Syscalls/kill.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Kernel/Syscalls/kill.cpp b/Kernel/Syscalls/kill.cpp index 84291d515ea..a9b72d2e374 100644 --- a/Kernel/Syscalls/kill.cpp +++ b/Kernel/Syscalls/kill.cpp @@ -11,11 +11,15 @@ namespace Kernel { ErrorOr Process::do_kill(Process& process, int signal) { - // FIXME: Allow sending SIGCONT to everyone in the process group. // FIXME: Should setuid processes have some special treatment here? auto credentials = this->credentials(); auto kill_process_credentials = process.credentials(); - if (!credentials->is_superuser() && credentials->euid() != kill_process_credentials->uid() && credentials->uid() != kill_process_credentials->uid()) + + bool can_send_signal = credentials->is_superuser() + || credentials->euid() == kill_process_credentials->uid() + || credentials->uid() == kill_process_credentials->uid() + || (signal == SIGCONT && credentials->pgid() == kill_process_credentials->pgid()); + if (!can_send_signal) return EPERM; if (process.is_kernel_process()) { dbgln("Attempted to send signal {} to kernel process {} ({})", signal, process.name(), process.pid());