Page MenuHomeFreeBSD

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

Authored by emaste on Jan 20 2022, 6:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 6, 3:26 PM
Unknown Object (File)
Tue, Nov 5, 4:10 AM
Unknown Object (File)
Mon, Nov 4, 8:19 AM
Unknown Object (File)
Fri, Oct 25, 6:23 AM
Unknown Object (File)
Fri, Oct 18, 8:43 AM
Unknown Object (File)
Thu, Oct 17, 8:24 AM
Unknown Object (File)
Wed, Oct 16, 3:08 AM
Unknown Object (File)
Mon, Oct 14, 6:26 AM
Subscribers

Details

Summary

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

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste created this revision.
This revision is now accepted and ready to land.Jan 20 2022, 11:27 PM

Could abandon this change if we change kern_procctl to skip the `error = cmd_info->need_candebug ? p_candebug(td, p) : p_cansee(td, p); in the case that we're operating on ourself.

The change in this review is good because it removes one syscall (not too big achievement on its own, but stil a right thing to do). Removing the unneeded calls in kernel are also good IMO, we do not envision that a process can be stripped from debugging permissions to itself [I believe Windows allows such thing].

This revision was automatically updated to reflect the committed changes.