DragonFlyBSD Kernel Audit
DF-3079 / fix.diff
← back to finding ↓ download raw
--- a/sys/vfs/procfs/procfs_vnops.c	2026-09-06 02:38:07.813579629 +0000
+++ b/sys/vfs/procfs/procfs_vnops.c	2026-09-06 02:38:07.813579629 +0000
@@ -237,8 +237,15 @@
 
 	switch (pfs->pfs_type) {
 	case Pmem:
-		if ((ap->a_fflag & FWRITE) && (pfs->pfs_flags & O_EXCL))
+		/*
+		 * Clear the exclusive-write latch on the LAST write close,
+		 * regardless of whether O_EXCL was used by this closer.
+		 * (v_opencount is still >= 1 here; vop_stdclose drops it.)
+		 */
+		if ((ap->a_fflag & FWRITE) &&
+		    ap->a_vp->v_opencount < 2) {
 			pfs->pfs_flags &= ~(FWRITE|O_EXCL);
+		}
 		/*
 		 * v_opencount determines the last real close on the vnode.
 		 *