From nobody Thu Feb 10 18:10:12 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 83C9B19B8BE5; Thu, 10 Feb 2022 18:10:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JvlCT1ZYfz3tMl; Thu, 10 Feb 2022 18:10:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644516613; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gZRMzCqxFRxQesAtj/rg6nENeOtTRRe6tbgJdT+tD28=; b=rM2kP3B9N+xzUHPbs7EX7NPmpoTxSUlaCZsH2Z+iIUIGOOZ+qRnlwuO2SILHhEBv4G7n+Z HJcYMJTst0UCbjHyuZqbHQLAD+eOmDnElFzIkUCFjf0qWifGgas9Ie4pB01mq4PzNNNk+d IdhsVx7N1g7K2rYrH1qQWg0WlOTdey3taJyDOUCMwQy25lMkblzK010bHoroZ85rjyj7Zq PdRSjlduq46eA+CXBXbGeRsiRaIBxrF0aP0MTRpLFran/wEMxrp6iMw+EDknrNL1tBBSZ+ hRbxXQdGud0Qogd9uy5yOuKrSzlOZQyWr5zSlM5ta/fhSCf85v4pVA2IAT6vCA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EF30A251CD; Thu, 10 Feb 2022 18:10:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21AIACxp006030; Thu, 10 Feb 2022 18:10:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21AIACon006026; Thu, 10 Feb 2022 18:10:12 GMT (envelope-from git) Date: Thu, 10 Feb 2022 18:10:12 GMT Message-Id: <202202101810.21AIACon006026@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 860508661c14 - stable/13 - ssh: pass 0 to procctl(2) to operate on self List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 860508661c14beb1e449c504ccb0bc5dafca60cc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644516613; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gZRMzCqxFRxQesAtj/rg6nENeOtTRRe6tbgJdT+tD28=; b=ldfdGFURuqAGwkM9cJKH5gKrQ7Z7fzCmKiqxcs5ZlFu0OxBiIuZqW+QkbYSVQfRlEs1sBS kNYYkkCDYlqPJ1JQH9dWoIjOb+BGyeW2loe7OfmO8x8Pdec2AiPw1F2OgWTybDxoBYusYu K/Ous9WvT4f89XYT7YoPh9CthXXwjm9TWg8ukOD4R5Y6WXgtQoL4ivQmbEMMLM8DhiZkuQ p9S4Z+QZHaEwkdnODT1RqOPlPK5G67k0UPncIZhqlTPHq8lHERmmCW/KE7NU34zRE4b/yG y+qTDDtngVRzITrh69AgZ9ACBXQaVpWBaDnDjPjeEwjhuxvIDPZsEC/WAOaEaw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644516613; a=rsa-sha256; cv=none; b=DuBcg9n1aVeq3dgL3Hm2ZDTvh6p+oRK/qaL/fxiZdKbBpXZ5AnD407bxEAV6LkVg1jWNNU +IjNHLr4PNAdwXQHO3gyrD943CeXMN6g/ZInP7kj0wOKGM8izCCHNhs3tcqw1Euur6V/Zf BWEUEw36X5VyJZvsTyKqiRpBydeyvjnrIbLDrreAvWjVFZsn6wx79jStcQsG3OUQ3tjkYX I5JFlnwQ82iv2spv8FPlyPX9fjHqPU7svhyF/JcQcDS9DHM56M1FyCyhZOYDg+fQ1GTkEa wiCehCUNk3c/VCqjTa91CuRQvtsT4C1sZ6ppHUkvgcnrut1Dlekqx8YHFE2/SQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=860508661c14beb1e449c504ccb0bc5dafca60cc commit 860508661c14beb1e449c504ccb0bc5dafca60cc Author: Ed Maste AuthorDate: 2022-01-20 18:41:39 +0000 Commit: Ed Maste CommitDate: 2022-02-10 18:09:57 +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) --- 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 /* For setpflags() and __PROC_PROTECT */ #endif #include -#include #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)