From bb1ad759c552aa9b767c67a16705e7a08234567a Mon Sep 17 00:00:00 2001 From: Itamar Date: Wed, 15 Sep 2021 15:42:45 +0300 Subject: [PATCH] Kernel: Allow calling sys$waitid on traced, non-child processes Previously, attempting to call sys$waitid on non-child processes returned ECHILD. That prevented debugging non-child processes by attaching to them during runtime (as opposed to forking and debugging the child, which is what was previously supported). We now allow calling sys$waitid on a any process that is being traced by us, even if it's not our child. --- Kernel/Syscalls/waitid.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Kernel/Syscalls/waitid.cpp b/Kernel/Syscalls/waitid.cpp index de0948745e6..f94025d9178 100644 --- a/Kernel/Syscalls/waitid.cpp +++ b/Kernel/Syscalls/waitid.cpp @@ -32,9 +32,12 @@ KResultOr Process::sys$waitid(Userspaceppid() != Process::current().pid()) { + if (!waitee_process) + return ECHILD; + bool waitee_is_child = waitee_process->ppid() == Process::current().pid(); + bool waitee_is_our_tracee = waitee_process->has_tracee_thread(Process::current().pid()); + if (!waitee_is_child && !waitee_is_our_tracee) return ECHILD; - } waitee = waitee_process.release_nonnull(); break; }