DragonFlyBSD Kernel Audit
DF-2642 / fix.diff
← back to finding ↓ download raw
--- a/sys/vfs/hammer2/hammer2_strategy.c	2026-08-29 16:03:17.911664684 +0000
+++ b/sys/vfs/hammer2/hammer2_strategy.c	2026-08-29 16:03:17.923664531 +0000
@@ -1295,10 +1295,24 @@
 				++hammer2_iod_file_wembed;
 			}
 		} else {
-			/* chain->error ok for deletion */
-			hammer2_chain_delete(*parentp, chain,
-					     mtid, HAMMER2_DELETE_PERMANENT);
-			++hammer2_iod_file_wzero;
+			/*
+			 * chain->error ok for deletion
+			 *
+			 * DF-2642: the chain_delete() return must be
+			 * propagated.  A failed deletion (typically the
+			 * parent COW allocation failing with ENOSPC on a
+			 * full PFS) leaves the old data chain intact in
+			 * the topology.  With the error dropped here the
+			 * strategy completion reports success, the clean
+			 * zero-filled logical buffer is accepted, and once
+			 * it is recycled reads resurrect the pre-overwrite
+			 * content with no error ever reported to userland.
+			 */
+			*errorp |= hammer2_chain_delete(*parentp, chain,
+							mtid,
+							HAMMER2_DELETE_PERMANENT);
+			if (*errorp == 0)
+				++hammer2_iod_file_wzero;
 		}
 		atomic_set_int(&ip->flags, HAMMER2_INODE_DIRTYDATA);
 		hammer2_chain_unlock(chain);