diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-02-28 11:45:45 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-02-28 11:46:38 +0100 |
commit | c09ab7cc40f4d9130d9253c550bb5bd820a14a59 (patch) | |
tree | 7fdb410911796e53e05ae3e612c8fe6152628f9f /Kernel/Process.cpp | |
parent | 05f925762135b97df8d8fb8c204eaf846e815191 (diff) | |
download | serenity-c09ab7cc40f4d9130d9253c550bb5bd820a14a59.zip |
Kernel: Only allow sending signals to process you own.
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r-- | Kernel/Process.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 954e56d0c2..ff50cb5d04 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1411,6 +1411,8 @@ int Process::sys$isatty(int fd) int Process::sys$kill(pid_t pid, int signal) { + if (signal < 0 || signal >= 32) + return -EINVAL; if (pid == 0) { // FIXME: Send to same-group processes. ASSERT(pid != 0); @@ -1424,13 +1426,18 @@ int Process::sys$kill(pid_t pid, int signal) Scheduler::yield(); return 0; } - Process* peer = nullptr; - { - InterruptDisabler disabler; - peer = Process::from_pid(pid); - } + InterruptDisabler disabler; + auto* peer = Process::from_pid(pid); if (!peer) return -ESRCH; + // FIXME: Allow sending SIGCONT to everyone in the process group. + // FIXME: Should setuid processes have some special treatment here? + if (!is_superuser() && m_euid != peer->m_uid && m_uid != peer->m_uid) + return -EPERM; + if (peer->is_ring0() && signal == SIGKILL) { + kprintf("%s(%u) attempted to send SIGKILL to ring 0 process %s(%u)\n", name().characters(), m_pid, peer->name().characters(), peer->pid()); + return -EPERM; + } peer->send_signal(signal, this); return 0; } |