[Bug 293871] procctl: add PROC_REAP_STATUS_EX for extended reaper subtree introspection

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 21 Mar 2026 19:44:06 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=293871

--- Comment #3 from Generic Rikka <rikka.goering@outlook.de> ---
After discussing the design off-list, I decided to rework the approach and move
away from introducing a new procctl interface returning derived reaper topology
data.

The main issue with the previous design is that it returned state that is only
consistent while the process tree lock is held, meaning the information can
become stale immediately after returning to userland. Given that, it makes more
sense to either reconstruct the data in userland or export only the minimal raw
information required to do so.

Following this direction, I am now extending struct kinfo_proc to export the
missing raw reaper metadata:

  - ki_reaper: pid of the owning reaper
  - ki_reapsubtree: subtree identifier

The existing kinfo_proc fields already provide pid and real-parent information,
so with these additions userland can reconstruct the reaper hierarchy from
kern.proc.all / kern.proc.proc without requiring a dedicated syscall or
kernel-side interpretation.

I believe this approach fits better with existing interfaces because:
  - it avoids introducing a new syscall for data already present in the kernel,
  - it keeps interpretation and policy in userland,
  - and it integrates naturally with existing sysctl and libkvm consumers.

The implementation updates:
  - fill_kinfo_proc() to populate the new fields under the appropriate locks,
  - libkvm (kvm_proclist) for crash dump consumers,
  - and the freebsd32 compatibility structures and copyout path.

I am currently running build and runtime tests (including a userland validation
program for reaper/subtree relationships). I will attach the revised patch and
test results once testing is complete.

-- 
You are receiving this mail because:
You are the assignee for the bug.