HomeFreeBSD

ssh: pass 0 to procctl(2) to operate on self

Description

ssh: pass 0 to procctl(2) to operate on self

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.)

At present if the security.bsd.unprivileged_proc_debug sysctl is 0 then
procctl(P_PID, getpid(), ... for a process to act on itself will fail,
but procctl(P_PID, 0, ... will succeed. This should likely be addressed
with a kernel change.

In any case the id = 0 shortcut is a tiny optimization for a process to
act on itself and allows the self-procctl to succeed, so use it in ssh.

Reported by: Shawn Webb
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33970

(cherry picked from commit 0746301c4995d9e4a82b0e5034b62e310694d1ef)
(cherry picked from commit e38610abcadbfeba5f7a32aa8a6bc8981be64908)

Details

Provenance
emasteAuthored on Jan 20 2022, 6:41 PM
Reviewer
kib
Differential Revision
D33970: ssh: pass 0 to procctl(2) to operate on self
Parents
rG8464ad72e087: ssh: update to OpenSSH v8.8p1
Branches
Unknown
Tags
Unknown