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.
This commit is contained in:
Itamar 2021-09-15 15:42:45 +03:00 committed by Andreas Kling
parent 6b4777c558
commit bb1ad759c5
Notes: sideshowbarker 2024-07-18 03:48:08 +09:00

View File

@ -32,9 +32,12 @@ KResultOr<FlatPtr> Process::sys$waitid(Userspace<const Syscall::SC_waitid_params
break;
case P_PID: {
auto waitee_process = Process::from_pid(params.id);
if (!waitee_process || waitee_process->ppid() != 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;
}