From nobody Thu Sep 28 15:10:35 2023 X-Original-To: dev-commits-src-main@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 4RxH3b50nlz4tttm; Thu, 28 Sep 2023 15:10:35 +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 4RxH3b45swz3XWQ; Thu, 28 Sep 2023 15:10:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695913835; 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=BniWYCjjhmPmlI2rfajkXezcRIyyqGeQkeNXx8sUoF0=; b=lNX0R0frnWZmVGQtNRXtxNo0DiHCYX7tPzr2Og+D1MCqUEaECb32KkJnDgZ9ZcbE5IniEW HX8ADP6aKmWmY3Ex5vGHMkxd0buCBB2CaihulOMvdVGcMIL6MMwYPsnDbQQbXGMWzjhcvb sKtZM+RrFP8k987QtgYQLYdkWkSokhK4+aVUCUbqU4kJeQ/1rnXRWMNhpnZntuSwwHObv0 RjDY+PDLeEjm8KUsms/F6X6+HyWspz4jXL/n2W+aMXYZPSQ7LXvGqjw0ArYz5ma/s7gv3R QWdZUIrmlcW/Yo7OPXwReTYD4QQQtcu8Z35gztGALNCabfoqlyqsRBGhi00zCQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695913835; a=rsa-sha256; cv=none; b=Yb9mAuRC3pTiW7lGZdjEQtWwfLpwojQ6MGo/nfa35EEWH7pUGb78uoi+1MT/cqP9sLn9tU Uz7s4y20wKwMfwyDAusFpXrSnZBvw4j/TGk4GOP34Bkdm9IUlhdNqEQVC0P5M1XPv+O1uY iqoYKY1DLaU6HiQPyPAbJYpfxAcaf9N67hjwNYu/T7e/l0iUv05zZXx7FyHp/8cmeKPUia ZIrHsUuAewzkmaB17ZSpTI/XSYRkxsRtj2y4wtp/Jt3RTsEZol/rD380s7PNhTbOTgZCpG 8Ge78bReSMqUdvYdxCeLU3v72X0v/YGZ72seuIU0Cbb0hU4BZahNHEbNMjMsdQ== 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=1695913835; 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=BniWYCjjhmPmlI2rfajkXezcRIyyqGeQkeNXx8sUoF0=; b=egXbSr6UDrnnjF7jABi5p7nepYykqgPyiOCH2EYciWdc2bTtR0Lz8h8ddDubSrMrKYWsRV EFWtLK5e+eLnCnf6cAFGQnK/BmKr1w+qsLRotVbdQ2I25MHYscpHycHINqvBJY/q3bIkmm NQaus04wIuUS+sdMX+G45v/xvEBHdY5eQTbyPP8QvfH2nKoF7EBuQcFJ9r25LWnQ5Gd61Y fR2Iohxwnoc1Vwk3LXDUA+4ikGRyxEeMJRIUps1rzeQN1tBKUAqUK+htGWLwhi3mezGgth pp3lpwMuoOvFiDIzGt0FzATaZrhVevS/xN/xTz/twKQaH/bEuQg0TqZxyMhMcw== 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 4RxH3b355fzBpj; Thu, 28 Sep 2023 15:10:35 +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 38SFAZ9t047202; Thu, 28 Sep 2023 15:10:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38SFAZNF047199; Thu, 28 Sep 2023 15:10:35 GMT (envelope-from git) Date: Thu, 28 Sep 2023 15:10:35 GMT Message-Id: <202309281510.38SFAZNF047199@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 5817169bc4a0 - main - Fix 'security.bsd.see_jail_proc' by using cr_bsd_visible() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 5817169bc4a06a35aa5ef7f5ed18f6cb35037e18 Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=5817169bc4a06a35aa5ef7f5ed18f6cb35037e18 commit 5817169bc4a06a35aa5ef7f5ed18f6cb35037e18 Author: Olivier Certner AuthorDate: 2023-08-17 23:54:38 +0000 Commit: Mitchell Horne CommitDate: 2023-09-28 14:59:08 +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 MFC after: 2 weeks Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40628 --- 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 1e6073b554e4..648c067dc528 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1471,11 +1471,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); } @@ -1536,9 +1532,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); /* @@ -1653,10 +1647,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); @@ -1723,9 +1716,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); /* @@ -1815,9 +1806,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); @@ -1847,7 +1836,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);