git: 3ac4831f360f - releng/15.2 - tmpfs: Clear setgid on creation by nonmembers
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Nov 2026 17:10:01 UTC
The branch releng/15.2 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=3ac4831f360f28bc0e3df50d99915ba69b561a80
commit 3ac4831f360f28bc0e3df50d99915ba69b561a80
Author: Kevin Day <kevin@your.org>
AuthorDate: 2026-11-14 01:40:14 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-17 13:37:26 +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: re (cperciva)
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 dd281d18d87d..b9643266caba 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -1167,6 +1167,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;
@@ -1195,9 +1196,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);