As of f833ab9dd187 procctl(2) allows idtype P_PID with id = 0 as a shortcut for the calling process ID. The shortcut also bypasses the p_cansee / p_candebug test (since the process is able to act on itself.)
Use the id = 0 shortcut in ssh so that the self-procctl will succeed.
It's likely the case that procctl(2) should allow the self-operation with getpid(). This change is suitable for the base system where we can be certain we are running on a kernel with f833ab9dd187 (and id = 0 is preferable anyway).
Reported by: Shawn Webb
Sponsored by: The FreeBSD Foundation