git: 36af45c63ddf - releng/14.5 - tmpfs: Clear setgid on creation by nonmembers
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Nov 2026 17:05:29 UTC
The branch releng/14.5 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=36af45c63ddfe4c56ec5c4aea4d33ea6d72be417
commit 36af45c63ddfe4c56ec5c4aea4d33ea6d72be417
Author: Kevin Day <kevin@your.org>
AuthorDate: 2026-11-14 01:40:14 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-16 21:17:13 +0000
tmpfs: Clear setgid on creation by nonmembers
New tmpfs nodes inherit their parent directory group. Clear S_ISGID when
the creator is not a member of that group and lacks PRIV_VFS_SETGID,
matching UFS and tmpfs chmod behavior.
Approved by: so
Security: FreeBSD-SA-26:94.tmpfs
Security: CVE-2026-127749
Reviewed by: kib
---
sys/fs/tmpfs/tmpfs_subr.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index bca6bf911eb1..40e242a07dd0 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -1164,6 +1164,7 @@ tmpfs_alloc_file(struct vnode *dvp, struct vnode **vpp, struct vattr *vap,
struct componentname *cnp, const char *target)
{
int error;
+ mode_t mode;
struct tmpfs_dirent *de;
struct tmpfs_mount *tmp;
struct tmpfs_node *dnode;
@@ -1192,9 +1193,15 @@ tmpfs_alloc_file(struct vnode *dvp, struct vnode **vpp, struct vattr *vap,
} else
parent = NULL;
+ mode = vap->va_mode;
+ if ((mode & S_ISGID) != 0 &&
+ !groupmember(dnode->tn_gid, cnp->cn_cred) &&
+ priv_check_cred(cnp->cn_cred, PRIV_VFS_SETGID) != 0)
+ mode &= ~S_ISGID;
+
/* Allocate a node that represents the new file. */
error = tmpfs_alloc_node(dvp->v_mount, tmp, vap->va_type,
- cnp->cn_cred->cr_uid, dnode->tn_gid, vap->va_mode, parent,
+ cnp->cn_cred->cr_uid, dnode->tn_gid, mode, parent,
target, vap->va_rdev, &node);
if (error != 0)
return (error);