From nobody Tue Sep 29 16:00:05 2026 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 4hvNDP6HS3z6tlXV for ; Tue, 29 Sep 2026 16:00:05 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hvNDP3MHWz4gs9 for ; Tue, 29 Sep 2026 16:00:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790697605; 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=loGvbgr+Qrxp7edURyKEw2US49p6L9GqAJySNiEf68Q=; b=xVUVOLcu0T4Veb6e1iS+aLcRlh/P3J1E5MB17r3KT1aZNVbUd2sRjPze3yITLkRJL0212f FyJYTJgGKabLDiqa89F+3CQvJUHTUy+UPDYSURZzNa5PHlrff651et1NJ7sk2muoqmiOxR fB/Wm/4FNo05D8Vf25ZT3XHGb28JddO5TOQ/nRY50L8CTGKglwsxTkGoO/5tchXBiZ/hhM xkqT6ml1Xr4nkQg2bHWy7dAfo5FpF3kMn+3jH8bhoaeg7h5vKpYPmXqJH+Z0vK/vUmVMJw fFPtyY8kpcmLeFFu62dfZ8inOAvPunA5alSxZqKx7TizKGni28AST6c6WfSq9Q== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1790697605; b=nvl2uUY2u4M7Ot4rAXgkr0gUgf35qdP87syNY/7cJcCSiz4ibPqxPjzNcKfhKJvJC128KL /Lu7KKaMa+esmYI2jpa/ZoYqPXR6zURqm0saGzgFti158iAfp1Dly1f55D0ZXft3atGQRt G90Y7Pun/UpUcM1bc3tR/q3Jzls+P1fF1qSnBIKOxBlT1aPwLXyDVwmDjscNE6ROMmI1lZ CgW60bKlekirA/VaZuxBxGXMpzc4uWYbZ/2uUuJoZ9JH0+ZBPwSUn4La+PDMBZjtfRNEOz LPQ6QqI+rPRtd39L3jmr4/k3CLaHysh76WESWD5oRqegBDlABgm+qZwB5iH5DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790697605; 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=loGvbgr+Qrxp7edURyKEw2US49p6L9GqAJySNiEf68Q=; b=c2WrTzU6ij/AQXv4FnriGxgNHEAqQZJI04ib/S/4OeubWpjCl3ABofq7zU2+5U3xxN5M2G OzrjOplQJtIIieT1xL+m3bkYpz4YPO3vz1JlIbD/FuZoDIl819NnBLIrIARhyrjSV4Rn14 bzy8QQARNWPs4lx3sTveNqyxOQCXY7Vqbabp4BcD6nV2Chc2pjO+HzSf+7xQ+w6HzbxJUc g63fqR1o+PbnIw1BRkqLqVXHi+SQoearsMW+ULfnXV5dJzqoArozPx+jHi+h3RHicjqeF9 TBWdKW+AkHpcktbQVEzYelRGtfcbPRNpiqxBgyKZfIhRJJrFYpJZDtdochvT9Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hvNDP1qZxz1KS1 for ; Tue, 29 Sep 2026 16:00:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3060e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 29 Sep 2026 16:00:05 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 08539f60ebeb - releng/15.1 - file: Add a helper function to check whether filecaps are full 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/15.1 X-Git-Reftype: branch X-Git-Commit: 08539f60ebeb748dfa5dab08bc098c766db1261a Auto-Submitted: auto-generated Date: Tue, 29 Sep 2026 16:00:05 +0000 Message-Id: <6abbe085.3060e.193d3b23@gitrepo.freebsd.org> The branch releng/15.1 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=08539f60ebeb748dfa5dab08bc098c766db1261a commit 08539f60ebeb748dfa5dab08bc098c766db1261a Author: Mark Johnston AuthorDate: 2026-09-28 14:42:29 +0000 Commit: Mark Johnston CommitDate: 2026-09-29 01:01:48 +0000 file: Add a helper function to check whether filecaps are full In a couple of places we want to know whether someone has limited rights on an fd. There, we want a predicate which determines whether the set of rights is smaller than CAP_ALL, and whether there are explicit ioctl or fcntl lists. Factor this out into a helper function, in preparation for use elsewhere. No functional change intended. Approved by: so Security: FreeBSD-SA-26:66.jail Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D59884 --- sys/kern/kern_descrip.c | 20 ++++++++++++-------- sys/sys/filedesc.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 2fa0621bdfca..e9ee752712f0 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1935,6 +1935,16 @@ filecaps_free(struct filecaps *fcaps) bzero(fcaps, sizeof(*fcaps)); } +bool +filecaps_full(const struct filecaps *fcaps) +{ + cap_rights_t allrights; + + CAP_ALL(&allrights); + return (cap_rights_contains(&fcaps->fc_rights, &allrights) && + fcaps->fc_fcntls == CAP_FCNTL_ALL && fcaps->fc_nioctls == -1); +} + static u_long * filecaps_free_prep(struct filecaps *fcaps) { @@ -3257,10 +3267,7 @@ fgetvp_lookup_smr(struct nameidata *ndp, struct vnode **vpp, int *flagsp) * * Not yet supported by fast path. */ - CAP_ALL(&rights); - if (!cap_rights_contains(&ndp->ni_filecaps.fc_rights, &rights) || - ndp->ni_filecaps.fc_fcntls != CAP_FCNTL_ALL || - ndp->ni_filecaps.fc_nioctls != -1) { + if (!filecaps_full(&ndp->ni_filecaps)) { #ifdef notyet ndp->ni_lcf |= NI_LCF_STRICTREL; #else @@ -3362,10 +3369,7 @@ fgetvp_lookup(struct nameidata *ndp, struct vnode **vpp) * all lookups relative to it must also be * strictly relative. */ - CAP_ALL(&rights); - if (!cap_rights_contains(&ndp->ni_filecaps.fc_rights, &rights) || - ndp->ni_filecaps.fc_fcntls != CAP_FCNTL_ALL || - ndp->ni_filecaps.fc_nioctls != -1) { + if (!filecaps_full(&ndp->ni_filecaps)) { ndp->ni_lcf |= NI_LCF_STRICTREL; ndp->ni_resflags |= NIRES_STRICTREL; } diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index c6499a18b884..2f9dedec1905 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -244,6 +244,7 @@ bool filecaps_copy(const struct filecaps *src, struct filecaps *dst, bool locked); void filecaps_move(struct filecaps *src, struct filecaps *dst); void filecaps_free(struct filecaps *fcaps); +bool filecaps_full(const struct filecaps *fcaps); int closef(struct file *fp, struct thread *td); void closef_nothread(struct file *fp);