Adds pdprocctl(2), which is procctl(2) specifying its target by a
process descriptor rather than by a pid, so process control stays
available in capability mode: pdprocctl(2) is CAPENABLED, while
procctl(2) itself is left as it was. Guarded by a new CAP_PROCCTL
right, which is not granted on the output of pdfork(2) or pdopenpid(2)
by default; a caller opts in with the PD_PROCCTL_CAP flag.
It is a pd-prefixed sibling sharing the implementation, as
pdptrace(2) (D58586) is for ptrace(2).
In capability mode, pdprocctl(2) accepts the commands D61919 marks
cap_enabled for a process acting on itself; the others fail with
ECAPMODE. The machine-dependent commands are not available through it
at all for now.
CAP_PROCCTL is one right covering all of procctl(2)'s otherwise
unrelated commands; limiting a descriptor to particular commands, as
cap_ioctls_limit(2) does for ioctl(2), is left for later.
A tiny kern_procctl_permit() is also factored out to make sure that
this one liner --- which now would have occurred in three, not two
places, otherwise --- doesn't drift out of sync.
The tests extend D61919's tests/sys/capsicum/procctl_test.c with the
same cases through a descriptor, plus the missing-right and
machine-dependent refusals.
Assisted-by: Claude Code (Claude Opus 5)