From nobody Tue Oct 17 19:43:23 2023 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 4S94Cc0lyPz4xvMD; Tue, 17 Oct 2023 19:43:24 +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 4S94Cc09l4z3K5y; Tue, 17 Oct 2023 19:43:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697571804; 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=l3J1BK5T67jLAE/JA5E3WaOozkhKw6oZvfCVQeArkpc=; b=A5qfNttqb/ittWiePODo8r/TL1XfDTqz6xeKf61epqsCeLeNimGmOsmaIuMDEOMHFiWVjs jLBzY7h6JwxgWKHOv6rgMt6Q89pczZ1tH+5IwjlFKXkhoHxVMsMb5NhbipCGztrwLAmogY SnbxgHKF+2c4xeofFZ16/OXk0EmHuYd1irRj5I4FxYv9GFEq9DtLdYLZDhQ5BhnvN4bEio JnznsVyHrbz/tQz2UBEBzNo+2D+FpwC2GAimje+U0G40pS+ngvv7SneAD1inHkLBeDnGkx W/CoMF9ejBcKApZDSaX1Ncz0G3+kXpH4Bi1yXkbFXT/PkPKIk46DvqmJRAYfBQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697571804; a=rsa-sha256; cv=none; b=VD+flQalgg/nHGGEyd3CBhVAGlled6Lud9JUNWwUTfjVLhiIHsABVFDtY4Jy2lSp0Xu/w9 sG01aXdYykDW0samqW7xhyyXTsOE8ckMiCSpbreHK3Ks7WpVMST8aObsvQrUlDLm7n3RIk ln2K9NSQVZkI9KR13fan6bfebIls+oPXcz76AQecEIl47s6/RqO5mKo1D5y404dg+SnUWv sWN5sEqcupUU++byc6hRZ2z2mgQbZZK4DkLhfXBsU/i05rb6OKvE4CSIUZ4uyYnCfSA+20 i3bcB7dB4NWie3eML7TBiruJyV+WzD2bnWr7HaM7DAiNssOw5CIulk9SuPK5kQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697571804; 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=l3J1BK5T67jLAE/JA5E3WaOozkhKw6oZvfCVQeArkpc=; b=sibA/laewBXiEFzRKRavgEkRYvNzqXOKPOIHnoTNLUgP0yAch26IRbHXxtIlOZrfT/Z1Jq Y2WDdX904WfOhjhph3rWe11KTqVL5sqoSMfAKfiFDhkIyn8UgIhLL4Axu20/C/gRqniig2 sTvEUj78jALrEbEsRiVnEOyFHhMJRS5dcIFpX+7wDu4TORPfKizrMX1X/GDx9/7eIvVyQI f5VwtfpLcoOscvgfAP4KUYR0jA8Xge7nM7sjS3RWT1szXfyDs861ELkkuyHanCcWvQ1gdi U8GQzZu/nrWJ666VKCqmhQTpuj6coeqNARJya34RURhLf2f3UEaB15+r6dJ9yQ== 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 4S94Cb6Jmdzcng; Tue, 17 Oct 2023 19:43:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39HJhNbR012801; Tue, 17 Oct 2023 19:43:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39HJhNlX012797; Tue, 17 Oct 2023 19:43:23 GMT (envelope-from git) Date: Tue, 17 Oct 2023 19:43:23 GMT Message-Id: <202310171943.39HJhNlX012797@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 9dad3ed1d15c - stable/14 - cr_canseejailproc(): New privilege, no direct check for UID 0 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: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 9dad3ed1d15c95c3eedb49c59e55bb25a7071250 Auto-Submitted: auto-generated The branch stable/14 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=9dad3ed1d15c95c3eedb49c59e55bb25a7071250 commit 9dad3ed1d15c95c3eedb49c59e55bb25a7071250 Author: Olivier Certner AuthorDate: 2023-08-17 23:54:37 +0000 Commit: Mitchell Horne CommitDate: 2023-10-17 19:42:58 +0000 cr_canseejailproc(): New privilege, no direct check for UID 0 Use priv_check_cred() with a new privilege (PRIV_SEEJAILPROC) instead of explicitly testing for UID 0 (the former has been the rule for almost 20 years). As a consequence, cr_canseejailproc() now abides by the 'security.bsd.suser_enabled' sysctl and MAC policies. Update the MAC policies Biba and LOMAC, and prison_priv_check() so that they don't deny this privilege. This preserves the existing behavior (the 'root' user is not restricted, even when jailed, unless 'security.bsd.suser_enabled' is not 0) and is consistent with what is done for the related policies/privileges (PRIV_SEEOTHERGIDS, PRIV_SEEOTHERUIDS). Reviewed by: emaste (earlier version), mhorne MFC after: 2 weeks Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40626 (cherry picked from commit 7974ca1cdbee949f5e453eea112be265b425c407) --- sys/kern/kern_jail.c | 1 + sys/kern/kern_prot.c | 7 +++++-- sys/security/mac_biba/mac_biba.c | 1 + sys/security/mac_lomac/mac_lomac.c | 1 + sys/sys/priv.h | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 39bdcaf5ef0e..57e6024a9939 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -3938,6 +3938,7 @@ prison_priv_check(struct ucred *cred, int priv) */ case PRIV_SEEOTHERGIDS: case PRIV_SEEOTHERUIDS: + case PRIV_SEEJAILPROC: /* * Jail implements inter-process debugging limits already, so diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 19e0b78c6709..ed15cb566499 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1426,9 +1426,12 @@ SYSCTL_INT(_security_bsd, OID_AUTO, see_jail_proc, CTLFLAG_RW, int cr_canseejailproc(struct ucred *u1, struct ucred *u2) { - if (u1->cr_uid == 0) + if (see_jail_proc || /* Policy deactivated. */ + u1->cr_prison == u2->cr_prison || /* Same jail. */ + priv_check_cred(u1, PRIV_SEEJAILPROC) == 0) /* Privileged. */ return (0); - return (!see_jail_proc && u1->cr_prison != u2->cr_prison ? ESRCH : 0); + + return (ESRCH); } /*- diff --git a/sys/security/mac_biba/mac_biba.c b/sys/security/mac_biba/mac_biba.c index 6948548503e1..5d66e2fd4b9b 100644 --- a/sys/security/mac_biba/mac_biba.c +++ b/sys/security/mac_biba/mac_biba.c @@ -1924,6 +1924,7 @@ biba_priv_check(struct ucred *cred, int priv) */ case PRIV_SEEOTHERGIDS: case PRIV_SEEOTHERUIDS: + case PRIV_SEEJAILPROC: break; /* diff --git a/sys/security/mac_lomac/mac_lomac.c b/sys/security/mac_lomac/mac_lomac.c index 05bd0da06960..aa9abf458721 100644 --- a/sys/security/mac_lomac/mac_lomac.c +++ b/sys/security/mac_lomac/mac_lomac.c @@ -1702,6 +1702,7 @@ lomac_priv_check(struct ucred *cred, int priv) */ case PRIV_SEEOTHERGIDS: case PRIV_SEEOTHERUIDS: + case PRIV_SEEJAILPROC: break; /* diff --git a/sys/sys/priv.h b/sys/sys/priv.h index 45cb5bab4275..a61de8d32fe0 100644 --- a/sys/sys/priv.h +++ b/sys/sys/priv.h @@ -105,6 +105,7 @@ #define PRIV_CRED_SETRESGID 58 /* setresgid. */ #define PRIV_SEEOTHERGIDS 59 /* Exempt bsd.seeothergids. */ #define PRIV_SEEOTHERUIDS 60 /* Exempt bsd.seeotheruids. */ +#define PRIV_SEEJAILPROC 61 /* Exempt from bsd.see_jail_proc. */ /* * Debugging privileges.