Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Feb 2022 16:05:08 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: b5b1a6960f33 - stable/12 - ssh: pass 0 to procctl(2) to operate on self
Message-ID:  <202202151605.21FG58ss072324@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=b5b1a6960f33d3afbfe12f7897644a52a0e5336b

commit b5b1a6960f33d3afbfe12f7897644a52a0e5336b
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-01-20 18:41:39 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-02-15 15:03:09 +0000

    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)
    (cherry picked from commit abf5f2e6932d6603c50c647a90d4e602e654003e)
---
 crypto/openssh/platform-tracing.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/crypto/openssh/platform-tracing.c b/crypto/openssh/platform-tracing.c
index 740a266b9432..0daf2a86f333 100644
--- a/crypto/openssh/platform-tracing.c
+++ b/crypto/openssh/platform-tracing.c
@@ -30,7 +30,6 @@
 #include <priv.h> /* For setpflags() and __PROC_PROTECT  */
 #endif
 #include <stdarg.h>
-#include <unistd.h>
 
 #include "log.h"
 
@@ -41,7 +40,7 @@ platform_disable_tracing(int strict)
 	/* On FreeBSD, we should make this process untraceable */
 	int disable_trace = PROC_TRACE_CTL_DISABLE;
 
-	if (procctl(P_PID, getpid(), PROC_TRACE_CTL, &disable_trace) && strict)
+	if (procctl(P_PID, 0, PROC_TRACE_CTL, &disable_trace) && strict)
 		fatal("unable to make the process untraceable");
 #endif
 #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202202151605.21FG58ss072324>