From d28fa89346e2142aae78b535ce4f3b45828ae781 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 27 Feb 2020 09:58:53 +0100 Subject: [PATCH] Kernel: Don't assert on sys$kill() with pid=INT32_MIN On 32-bit platforms, INT32_MIN == -INT32_MIN, so we can't expect this to always work: if (pid < 0) positive_pid = -pid; // may still be negative! This happens because the -INT32_MIN expression becomes a long and is then truncated back to an int. Fixes #1312. --- Kernel/Process.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 7d162fe524..683c71f582 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -2213,8 +2213,11 @@ int Process::sys$kill(pid_t pid, int signal) if (signal < 0 || signal >= 32) return -EINVAL; - if (pid <= 0) + if (pid <= 0) { + if (pid == INT32_MIN) + return -EINVAL; return do_killpg(-pid, signal); + } if (pid == -1) { // FIXME: Send to all processes. return -ENOTIMPL;