From nobody Tue Feb 15 16:05:08 2022 X-Original-To: dev-commits-src-branches@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 60A7219B9FFA; Tue, 15 Feb 2022 16:05:08 +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 4JymBr1zPFz3r2D; Tue, 15 Feb 2022 16:05:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644941108; 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=0Lgf2JUd9hunV+SV7rf5DLLJrA/4L5vxvpe9Z7qq34Y=; b=xWILwULw9P5dY9gCim14eHnLZVD7hqkcRz5CA+WQ644Ymbw5NJRLZ3E13aIfhbRpjF83x0 n3ErkKmQxKYP6Fzs5Ku47bxrHcBAZ6OjZLZIaO3huP2IEG5i+RGyei3ZMeiXGFRGrpru0I HjBzVrRFuUHrmKat5UNFBtxybbj67DL2sSjlH6o/dCsJy3Ug9T0XgFqeH7c4ut6lV2STnn kJZV+sfGNv5k0H4Pfyy0ABeHtvK373zVEBxMLq0bCf+uO6yWZDE3UdHawGOoVvX+bxsGvm szJQ+CRT2vfLhrvIntsPRNSyDRhrhVzd2LHcjJKoPBsqyMz49ff10E4PhojZEg== 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 24294251C3; Tue, 15 Feb 2022 16:05:08 +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 21FG58V2072325; Tue, 15 Feb 2022 16:05:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21FG58ss072324; Tue, 15 Feb 2022 16:05:08 GMT (envelope-from git) Date: Tue, 15 Feb 2022 16:05:08 GMT Message-Id: <202202151605.21FG58ss072324@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: b5b1a6960f33 - stable/12 - ssh: pass 0 to procctl(2) to operate on self List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/12 X-Git-Reftype: branch X-Git-Commit: b5b1a6960f33d3afbfe12f7897644a52a0e5336b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644941108; 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=0Lgf2JUd9hunV+SV7rf5DLLJrA/4L5vxvpe9Z7qq34Y=; b=P8XJBfmzyldFHmdHXdkvqgSqKrOWpKJerseQAM1Tdyz0v9UYhFl43JtoGfOdfMcmU+8u7T Td0HWkCB8i8i/TFTnuIAF9DipjE9uVIlqkR0BivK08YOfXXlVo5UJuHDXMl+bQBGjhwwn4 Ky8oPBDTlnH7fut5Y+F6Pa0Oow+y7S/aFQ3Az6cHrfQf8ZQriQGQrezwWWqKe10oiWytfm 3wzrzvQ7nWQb3t3YF3F1TAYnvLqECK3wgMcqlYxUuQr8o1F6fWDVzM8WQrjNgFULVD/VKl E3wWE5n5lwdt9NyLDbryE3kf/NxTKYWC6yiRUOBMKzbqynHlQAc8TBGnBc7TKg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644941108; a=rsa-sha256; cv=none; b=D5dpL/y7B+Axu8Mmyq5En3TUMLvT+1gNPwxoagzLFjl6Ir5lhga7hKMFQv11sz8bZwE1UG TgHnyhVJCLrWAqARo2ynE1tqlf31mdmYDFSPC/oTw0xj9jYpTyJd1RZWgaUUVBumrsVm5W EzossdXrxFVUNP43Z2sWnSKD595N9p9iG4VwQaHHkEEJTQPa1FdAPXF6DzMoYHar9tdThu hO6xpsKID4JAcSEtceLW+3X/d1+ussjZy3ZKt23SSqKU6CKlm/ffvZmtbJxGsgydDdxAF1 dW2QksWQW9XlvDccpV9ZQPxkeb++VA/K2qL0odv0fKMZMsnn/T9UaPDhDK7nsg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=b5b1a6960f33d3afbfe12f7897644a52a0e5336b commit b5b1a6960f33d3afbfe12f7897644a52a0e5336b Author: Ed Maste AuthorDate: 2022-01-20 18:41:39 +0000 Commit: Ed Maste 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 /* 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)