⬢ DragonFlyBSD Kernel Audit
DF-3034 / fix.diff
← back to finding ↓ download raw
--- a/sys/vfs/hammer/hammer_io.c	2026-06-29 12:51:19.000000000 +0000
+++ b/sys/vfs/hammer/hammer_io.c	2026-10-26 03:28:07.213962267 +0000
@@ -1655,6 +1655,14 @@
 		 */
 		obp->b_flags |= B_ERROR;
 		obp->b_error = bp->b_error;
+	} else if (bp->b_bufsize < obp->b_bufsize) {
+		/*
+		 * The device buffer does not cover the request.  Never
+		 * trust the (fragile) buffer-size match below to hold:
+		 * fail the I/O instead of running the CRC/bcopy OOB.
+		 */
+		obp->b_flags |= B_ERROR;
+		obp->b_error = EIO;
 	} else if (obio->bio_caller_info2.index &&
 		   obio->bio_caller_info1.uvalue32 !=
 		    hammer_datacrc(hmp->version,
@@ -1671,9 +1679,8 @@
 		obp->b_error = EIO;
 	} else {
 		/*
-		 * Everything is ok
+		 * Everything is ok (size gate handled above)
 		 */
-		KKASSERT(bp->b_bufsize >= obp->b_bufsize);
 		bcopy(bp->b_data, obp->b_data, obp->b_bufsize);
 		obp->b_resid = 0;
 		obp->b_flags |= B_AGE;