From nobody Thu Dec 21 13:43:25 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 4Sws8F4Lc6z54pYv; Thu, 21 Dec 2023 13: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 4Sws8F1zFrz4NLb; Thu, 21 Dec 2023 13: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=1703166205; 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=YTvT4jV8Q08wALJVO7oBXtRc17exElzc3JsBRjkWNl8=; b=WjfphLMo/C/1buWaf1GyR8p9TrR/jO1WDn+kFKxVNYsAVKc6MWRVu5lpIwB4KQPNSwiBfA WXAFnQkJxGUJ08A5ZZssvhvYgUCrdLn3og3q+SXHwG/FvxSl72EOP+41okRBJKC/FnoTfj BJCWaneeeZ1mOjSpbilpIxrezVcRsKEMvuMbm6MCpiIeLQ6XIrSUacXZG460/t0M38C6ps mceE6POn3ZANcZqUTaA1Owz8hYRLUdQGrJSTFLRLOi3wRHbZPYuC7jz8ycMxxM0NBLywxW zj/2cU/wGFTiCRjgVwEff2kZeULhylQBpYCntwmNuTHu744bCTBk/GDjX002LA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703166205; a=rsa-sha256; cv=none; b=ch+8Ju7w6QOsfLrpgo5StQy/+YbGHAi7Q0YTLA8QKwFtcCcqc7Ftr3Z+wPhuoUxtOM7zDJ mNkYWFElm8r6qzmm4pcLTk10XgYg+JJNdqs/my7vV5RbZi7UOOIdZjZqJFMEV4Vd1W7WWB QF3QbmhGXZM9geZxqIsb9r4BE/eyTHP8Ebo2ONW6Oo/f0Tui0OdLHsQLAglexYH2lcb2WE JlekNqnn9BYwFMQxbxXLrbsEdBRudojbzXloCEuEtPMjy4XOAAE38LuOiyqQ7p4UaQDSqZ QGnVK23PVTsyIqrnsN6ICmbLfmg9aheGTOGEYFIb+zL0vV0tUNXwalF6LOPV6Q== 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=1703166205; 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=YTvT4jV8Q08wALJVO7oBXtRc17exElzc3JsBRjkWNl8=; b=s0loq3D8wdIJD+5gUbyu43SeUoI8XR94CC4/2EeJgGNdioRw7DK6yX9iKNCxodT8TCo0W0 HJA9y/4S1RjuYUBs3EtSr2huafLI5307V0R19WyUC+KyLlPjWcnqveYB5mMCONSWg1T6uf f9FcnVYDX3yZE8ZyAr5MMgFByntDJ//CyFVqd2M9Xoy/xjkGh3jvN6Upr2qxLlPPyLNZX3 +wwLI07kF8dmZaPNqHJbYs3phdSUzrC/TYWB8a4rpzEzh74ZNdfLqkFgewsj4eTdYNO6Vu kXAWZyVQlSvtL5GCAbkju2s7PyAaT6DDRXLfuI+epDER7kUTkYPZH7ynLIelqQ== 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 4Sws8F0v3JzZRS; Thu, 21 Dec 2023 13: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 3BLDhPGr078680; Thu, 21 Dec 2023 13:43:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BLDhPiq078677; Thu, 21 Dec 2023 13:43:25 GMT (envelope-from git) Date: Thu, 21 Dec 2023 13:43:25 GMT Message-Id: <202312211343.3BLDhPiq078677@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: 9a4a7e5fb6e9 - stable/13 - Fix 'security.bsd.see_jail_proc' by using cr_bsd_visible() 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: 9a4a7e5fb6e901e81c8e64a988358ad4b59464a5 Auto-Submitted: auto-generated The branch stable/13 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=9a4a7e5fb6e901e81c8e64a988358ad4b59464a5 commit 9a4a7e5fb6e901e81c8e64a988358ad4b59464a5 Author: Olivier Certner AuthorDate: 2023-08-17 23:54:38 +0000 Commit: Olivier Certner CommitDate: 2023-12-21 13:36:17 +0000 Fix 'security.bsd.see_jail_proc' by using cr_bsd_visible() As implemented, this security policy would only prevent seeing processes in sub-jails, but would not prevent sending signals to, changing priority of or debugging processes in these, enabling attacks where unprivileged users could tamper with random processes in sub-jails in particular circumstances (conflated UIDs) despite the policy being enforced. PR: 272092 Reviewed by: mhorne Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40628 (cherry picked from commit 5817169bc4a06a35aa5ef7f5ed18f6cb35037e18) Approved by: markj (mentor) --- sys/kern/kern_prot.c | 25 +++++++------------------ sys/netinet/in_prot.c | 4 +--- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 8118afd4d366..7f196a446315 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1473,11 +1473,7 @@ cr_cansee(struct ucred *u1, struct ucred *u2) if ((error = mac_cred_check_visible(u1, u2))) return (error); #endif - if ((error = cr_canseeotheruids(u1, u2))) - return (error); - if ((error = cr_canseeothergids(u1, u2))) - return (error); - if ((error = cr_canseejailproc(u1, u2))) + if ((error = cr_bsd_visible(u1, u2))) return (error); return (0); } @@ -1538,9 +1534,7 @@ cr_cansignal(struct ucred *cred, struct proc *proc, int signum) if ((error = mac_proc_check_signal(cred, proc, signum))) return (error); #endif - if ((error = cr_canseeotheruids(cred, proc->p_ucred))) - return (error); - if ((error = cr_canseeothergids(cred, proc->p_ucred))) + if ((error = cr_bsd_visible(cred, proc->p_ucred))) return (error); /* @@ -1655,10 +1649,9 @@ p_cansched(struct thread *td, struct proc *p) if ((error = mac_proc_check_sched(td->td_ucred, p))) return (error); #endif - if ((error = cr_canseeotheruids(td->td_ucred, p->p_ucred))) - return (error); - if ((error = cr_canseeothergids(td->td_ucred, p->p_ucred))) + if ((error = cr_bsd_visible(td->td_ucred, p->p_ucred))) return (error); + if (td->td_ucred->cr_ruid != p->p_ucred->cr_ruid && td->td_ucred->cr_uid != p->p_ucred->cr_ruid) { error = priv_check(td, PRIV_SCHED_DIFFCRED); @@ -1725,9 +1718,7 @@ p_candebug(struct thread *td, struct proc *p) if ((error = mac_proc_check_debug(td->td_ucred, p))) return (error); #endif - if ((error = cr_canseeotheruids(td->td_ucred, p->p_ucred))) - return (error); - if ((error = cr_canseeothergids(td->td_ucred, p->p_ucred))) + if ((error = cr_bsd_visible(td->td_ucred, p->p_ucred))) return (error); /* @@ -1819,9 +1810,7 @@ cr_canseesocket(struct ucred *cred, struct socket *so) if (error) return (error); #endif - if (cr_canseeotheruids(cred, so->so_cred)) - return (ENOENT); - if (cr_canseeothergids(cred, so->so_cred)) + if (cr_bsd_visible(cred, so->so_cred)) return (ENOENT); return (0); @@ -1851,7 +1840,7 @@ p_canwait(struct thread *td, struct proc *p) #endif #if 0 /* XXXMAC: This could have odd effects on some shells. */ - if ((error = cr_canseeotheruids(td->td_ucred, p->p_ucred))) + if ((error = cr_bsd_visible(td->td_ucred, p->p_ucred))) return (error); #endif diff --git a/sys/netinet/in_prot.c b/sys/netinet/in_prot.c index 222e39c6bcd2..204f4f60456e 100644 --- a/sys/netinet/in_prot.c +++ b/sys/netinet/in_prot.c @@ -67,9 +67,7 @@ cr_canseeinpcb(struct ucred *cred, struct inpcb *inp) if (error) return (error); #endif - if (cr_canseeotheruids(cred, inp->inp_cred)) - return (ENOENT); - if (cr_canseeothergids(cred, inp->inp_cred)) + if (cr_bsd_visible(cred, inp->inp_cred)) return (ENOENT); return (0);