Issue #3473 has been updated by tuxillo. Status changed from New to Resolved
---------------------------------------- Bug #3473: tmpfs, HAMMER and HAMMER2 keep the setgid bit on files created by non-members http://bugs.dragonflybsd.org/issues/3473#change-14978 * Author: tuxillo * Status: Resolved * Priority: Normal * Target version: 6.6 * Start date: 2026-11-20 ---------------------------------------- As of master d37499e259, if you create a file on tmpfs, HAMMER or HAMMER2 in a directory owned by a group you're not in, and ask for S_ISGID, you keep it. The file gets the directory's group, so any user can make a setgid binary for a group they don't belong to. /tmp on tmpfs is root:wheel 1777, so that means wheel. UFS gets this right: ufs_makeinode() drops the bit unless the creator is in the group or has the privilege. tmpfs_alloc_file(), hammer_create_inode() and hammer2_inode_create_normal() don't do that check. To reproduce, as root make a directory owned by a group your user isn't in, then run the attached sgid_create.c as that user: <pre> # install -d -o root -g operator -m 1777 /tmp/sgid.tmpfs $ cc -o sgid_create sgid_create.c $ ./sgid_create /tmp/sgid.tmpfs /tmp/sgid.tmpfs/sgid_create.3048: mode 2755 group operator: set-group-ID kept, WRONG </pre> The program's header has the output on tmpfs, HAMMER2 and UFS before the patch, and on those plus HAMMER after it. The attached patch adds the UFS check to the three filesystems. Root and members of the group still get 2755. FreeBSD fixed the tmpfs side of this in FreeBSD-SA-26:94.tmpfs (CVE-2026-127749). ---Files-------------------------------- sgid_create.c (2.88 KB) 0001-vfs-drop-S_ISGID-on-create-when-not-a-member-of-the-.patch (3.94 KB) -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account
