From nobody Tue Oct 17 19:43:24 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 4S94Cd3pnnz4xvRv; Tue, 17 Oct 2023 19:43:25 +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 4S94Cd1Kbsz3K6F; Tue, 17 Oct 2023 19:43:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697571805; 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=c4+w3xO6Whz8QKn6nec+f2j1fnzQy31oVaH9E3nrjmA=; b=q39ZXOCuOXOvSe7wSA/ciOSziUPsh9vvBBvxhMALANSewbarkC+oEIfEZia8ja8rUw0fPI CPYHwh7z5K8fLiIibqQf6PXM4+7lzvhPwy4Sp/m2/bfAXJ51TAGHSLYyHNivwBetr/UeIm rbLF+4VwPRxEiH2HWfrGJDpWAn8yGP9jZfJcxzqLOMTUOzQpXqcZHAsieYg+IjDdDBH6mY qLbMDmYvOZ+XkHjXQBSCMi33MnKooCV7vZI6Smp3mRLAcyh08l6lYS/SV/OLte25yCqBub BzozVRGVBPvCfXlfZQWy0g9FZCxvn6Acpklb9hIgxYS8w68UiXoWjPj+q1Ibtg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697571805; a=rsa-sha256; cv=none; b=sPYU7djcxcvA38OmY5JcvK+yHii8g1ZFTi1bApWu0a/XTEtSS10ACbP8JuEe4eTymU/CaY Ggi0211+YGDXF/Og2tRFd7yZuf3bTXdBOa1lU7udNDTe75uQRI+qvf9fOC3NmD8polaLlk NW/TS5JOadrbME0fE1MVLge6Bblj2fNVWgL0ZyatXWTYxILOxhOGHBKlk9P20hZ3ysv5OI FoA7Q8aeVQFiLTVpmFeOmnwRH5zS7T5DGEhJYN+KSMmC7sPqkX/CjvFPUAYnSVz/4UZuXM oQn6X5mjEiSXM3BCFKG87y9fN0Ehg1+TzTTgmL5ykRQQTN2cYWtrASlshJ2kUg== 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=1697571805; 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=c4+w3xO6Whz8QKn6nec+f2j1fnzQy31oVaH9E3nrjmA=; b=idXLxX3u3IuPVQdWV/7aR+8geu9mQAWWdv4bo+gWRlFiPm+bEZ4z8ko/Ph2/hvm/uj29jW FSFtWM9NlcMtl+BHEeyRJVEuZQOhzWaKFImAa3rhwrGKZFyAK35oUsKyiavHIGvCmgcr0L kvSxALntn7miM1szKZN+B3uDFORpC41yWCvJ6kcc1s8WaM+ISaYt8wGYh3k/0zBhoiSspO f8FYv/qL4m2J4RvJD/Fq4afItK7acX1nZXIx0Qk4jEM1qd8uBGLjpd/R57hqOjp8TwiFgX Oo6Rk1Ag9awRmbEWeyOtWpq0AoKzDtHgQKVGgwI5W+ijXreEDQxHypw5RcTT3Q== 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 4S94Cd0CFszcbl; Tue, 17 Oct 2023 19:43:25 +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 39HJhOBG012855; Tue, 17 Oct 2023 19:43:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39HJhOhx012852; Tue, 17 Oct 2023 19:43:24 GMT (envelope-from git) Date: Tue, 17 Oct 2023 19:43:24 GMT Message-Id: <202310171943.39HJhOhx012852@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: 3ad322db8902 - stable/14 - 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: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 3ad322db8902da1c3d3669471e4e5738f980a849 Auto-Submitted: auto-generated The branch stable/14 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=3ad322db8902da1c3d3669471e4e5738f980a849 commit 3ad322db8902da1c3d3669471e4e5738f980a849 Author: Olivier Certner AuthorDate: 2023-08-17 23:54:38 +0000 Commit: Mitchell Horne CommitDate: 2023-10-17 19:42:58 +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 MFC after: 2 weeks Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40627 (cherry picked from commit e4a7b4f99cfd4931468c0866da4ae8b49cf5badb) --- 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 ed15cb566499..1e6073b554e4 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1434,6 +1434,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 3102cae7add0..8609bbd124ad 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1163,6 +1163,7 @@ void ast_sched(struct thread *td, int tda); void ast_unsched_locked(struct thread *td, int tda); 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);