From nobody Wed Oct 18 18:03:40 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 4S9dy43LDJz4xL1k; Wed, 18 Oct 2023 18:03:40 +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 4S9dy42kVBz4WlQ; Wed, 18 Oct 2023 18:03:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697652220; 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=J5Mmdtz+xO17AXLm8f5rWGl9568tdRHuMQzQt1RTu3Q=; b=NroT/QUYReyUWPCjHCorZrzliqgtK68C8xq29n5ewA1Yzbaa/l80cU658TZ8NbE6v9D6yi 0Nae0c90M/m2n6x/K4HgpOPCEh0INuONZ4nqtFgnoXcz+IaTSlIeZ+aFD5BVl0iO6ELox6 m2Ks5JdfCZEGroGrZcQqH4SLXi/FleIBaGIDQYGGZlfcp7amGZF1L62u6yLPSkMsiG2cwB 2UhYE9OfV1cC/Zy7C6RNO3hsnXZK96xIW/5mgRNIUngAk6vul4uVKQti4K8XJsEXSEuOln JOf2ypbQ2LIjEMvw515RChLDCsbKd4rXhbGGvwIkKOMlcj+DkzIfBq3IkSumiA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697652220; a=rsa-sha256; cv=none; b=DCoxlIMARBctyn7s8IsuKhyQS1JOW28/nuJkf/2iLTvZNQAY6aC7qrLt9IixzVavit0T3t vYWl4ieeRiyTT0nBe9GZFbjD5Hjf1Yyo+ekoKYTyBLi2TlUh8qCmhFTr/bj3YLVLZ6eJBu OjmpwlXYM98GJzQaY8mDvsnDBouIQAALNesVN0osaWoNWqN1ZOoYOf7h63FmTO4CsYMLDE Yg+oqCR48O233+SQcEU1BczxcDWDOnXUhA8Tpt9wC7xVnvkuv9udxSkkeFiSuT6AW8QMBM iDztA5+7uaSPz6QycuxPn6TJ0P+rtoJiAMiulQc9CI2b7ak80/dGpZWpy8Ob6g== 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=1697652220; 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=J5Mmdtz+xO17AXLm8f5rWGl9568tdRHuMQzQt1RTu3Q=; b=koPwpZ6q7ekDptv9w3uq6O/D1EFY71mp0RaGHi6eQYzGWSUtoKoqA4ULXbmsBEdnjCtYh3 ti67YjSH/OAUgsW82tQndbxdPUuT1kRlvBU+SGDZ8hNAAIv1sBmvJjPgtCw6C4vlUox6ZV Iy7ssBVXHZESznwtevECNs9z6JQNAQcublu2A4jvieHhQ4hBYY35lfQK9+UPclFkkMfDkK RyZ2Zch5vs2yD3E2zomfCr4xjUrg7RefEIYknPN5oIWHvWmE0UTYjXHf3UqvIEm3SXwv/+ oRGQA2GceJ4+wEAG5EfhI0aHnqh5ES8GEjrpBdvoKW9B7kNvXlbuW0ZraA75og== 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 4S9dy41p6mz24m; Wed, 18 Oct 2023 18:03:40 +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 39II3eJC044314; Wed, 18 Oct 2023 18:03:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39II3eRl044311; Wed, 18 Oct 2023 18:03:40 GMT (envelope-from git) Date: Wed, 18 Oct 2023 18:03:40 GMT Message-Id: <202310181803.39II3eRl044311@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: 63c01c18a8d3 - releng/14.0 - 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/releng/14.0 X-Git-Reftype: branch X-Git-Commit: 63c01c18a8d3feb957a4f91171aaac1f92ce5955 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=63c01c18a8d3feb957a4f91171aaac1f92ce5955 commit 63c01c18a8d3feb957a4f91171aaac1f92ce5955 Author: Olivier Certner AuthorDate: 2023-08-17 23:54:37 +0000 Commit: Mitchell Horne CommitDate: 2023-10-18 17:59:09 +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). Approved by: re (gjb) Reviewed by: emaste (earlier version), mhorne Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40626 (cherry picked from commit 7974ca1cdbee949f5e453eea112be265b425c407) (cherry picked from commit bedaf8af51c96cef025c13c41ba420163824e8cb) --- 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.