From nobody Thu Dec 21 13:43:23 2023 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 4Sws8D1pmhz54pNq; Thu, 21 Dec 2023 13: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 4Sws8D0nphz4N95; Thu, 21 Dec 2023 13: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=1703166204; 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=hv51WFtqd268JW9XDM2mf4wfLd/FP6x2xHhv+VB2B+M=; b=yUHiuWngKCjbmlzD5LYE/A1EDh1tWTltf98IKKXfV+c8zfnkp7sblkgBIcJ+4KkzkwRKVE M142qTC/RiNmWdIs0bGP46A71GXz4XLkWtyndykAlhUMSHlNBW/c1fPymhF+DnaNnbAfh1 PSWYWEGwtPOCwqicYNoNE6dxhACcUN5TMrXMYwEUm49cQHA9oOHcSNw5e1jBZiFP8Qtn8w pHccfLJtZnjgy02jPimpQZy9lJSAg0g8Acws9QwPgpF90us3cJNGlVbtZYPpK7sC6ExcRz lgYObmHQHLwPLIO1sBBNf3fG4LUM2u+YTuyQAuxcj2DvYNzKhK1cFJk9HX/pPQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703166204; a=rsa-sha256; cv=none; b=DytpbCtbaURGPa2y0EzETBJJKUVAsluGsnqFmvOeuj2YLfEazNOEGjP9WcaKEzu9gYfcly KEbyoKxoIFLpowxX/9IEc2//ThOy7qZz5HFQxEyIzG7rIpUXATfBiCT8lb8nwx+bsz573Q LOkrri9nAezHdPrQne7W8F8LxE9TvZQIkNpM9Nr1zTKnC0k1wRYT6SlfGklIXrVU0LposT 7CiD0FJD42ngUTFQ3hdHKNbpoSBXReife5in3pseHHacg+lR3mjEkL1NVFUmTBi7WruQqI Ho6ihag0N5raNNUnudlM23FnOoH9fR0tXN6OTPMWHj9kqctzWmwZs4oigdjx+w== 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=1703166204; 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=hv51WFtqd268JW9XDM2mf4wfLd/FP6x2xHhv+VB2B+M=; b=JD67Lr3jTCQRpaN6PeeIl4KI9/XcxWvNDgE+DnBQQuDOR7+iDdLtJmCUuJr3OKMZa70TD6 sDNbRP77b5KvhhFLvI7dWSaAMA/xRX1UkQV/5nZBskUcoI6eYekph/fDiy4jvgt8fOrrfR Zlu6R++L2YugNR66JerdBQaIy+P/wHZOKu6LU7RmEqOtztayQ6YSi44JQ6kRlvsZdcZ+Dn oTWE+M1nDQ0toFE7uSg1b3kKG1b8AUpmKC4x+4V6eGlUQpOByoG/6OxIP7fpO5x6jH7r2s yeTaolM+h8umHCKGrLd8HcV/JuYkqBO3HjDOkdgf2sSiW0+AzG5BYZuDp8+M2Q== 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 4Sws8C700jzb5p; Thu, 21 Dec 2023 13: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 3BLDhN6E078638; Thu, 21 Dec 2023 13: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 3BLDhNu0078635; Thu, 21 Dec 2023 13:43:23 GMT (envelope-from git) Date: Thu, 21 Dec 2023 13:43:23 GMT Message-Id: <202312211343.3BLDhNu0078635@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 0dafeb5bc874 - stable/13 - New cr_bsd_visible(): Whether BSD policies deny seeing subjects/objects 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: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0dafeb5bc874d79907cc25b3c8dc14f9ed55b396 Auto-Submitted: auto-generated The branch stable/13 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=0dafeb5bc874d79907cc25b3c8dc14f9ed55b396 commit 0dafeb5bc874d79907cc25b3c8dc14f9ed55b396 Author: Olivier Certner AuthorDate: 2023-08-17 23:54:38 +0000 Commit: Olivier Certner CommitDate: 2023-12-21 13:36:09 +0000 New cr_bsd_visible(): Whether BSD policies deny seeing subjects/objects This is a new helper function that leverages existing code: It calls successively cr_canseeotheruids(), cr_canseeothergids() and cr_canseejailproc() (as long as the previous didn't deny access). Will be used in a subsequent commit. Reviewed by: mhorne Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40627 (cherry picked from commit e4a7b4f99cfd4931468c0866da4ae8b49cf5badb) Approved by: markj (mentor) --- sys/kern/kern_prot.c | 19 +++++++++++++++++++ sys/sys/proc.h | 1 + 2 files changed, 20 insertions(+) diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 8b56ba3f8846..8118afd4d366 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1436,6 +1436,25 @@ cr_canseejailproc(struct ucred *u1, struct ucred *u2) return (ESRCH); } +/* + * Helper for cr_cansee*() functions to abide by system-wide security.bsd.see_* + * policies. Determines if u1 "can see" u2 according to these policies. + * Returns: 0 for permitted, ESRCH otherwise + */ +int +cr_bsd_visible(struct ucred *u1, struct ucred *u2) +{ + int error; + + if ((error = cr_canseeotheruids(u1, u2))) + return (error); + if ((error = cr_canseeothergids(u1, u2))) + return (error); + if ((error = cr_canseejailproc(u1, u2))) + return (error); + return (0); +} + /*- * Determine if u1 "can see" the subject specified by u2. * Returns: 0 for permitted, an errno value otherwise diff --git a/sys/sys/proc.h b/sys/sys/proc.h index b279839dbf8d..a85ae239f46b 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1095,6 +1095,7 @@ int pget(pid_t pid, int flags, struct proc **pp); void ast(struct trapframe *framep); struct thread *choosethread(void); +int cr_bsd_visible(struct ucred *u1, struct ucred *u2); int cr_cansee(struct ucred *u1, struct ucred *u2); int cr_canseesocket(struct ucred *cred, struct socket *so); int cr_canseeothergids(struct ucred *u1, struct ucred *u2);