⬢ DragonFlyBSD Kernel Audit
DF-2725 / fix.diff
← back to finding ↓ download raw
--- sys/kern/vfs_cluster.c	2026-06-29 12:51:19.000000000 +0000
+++ /tmp/opencode/v26/fixtree/sys/kern/vfs_cluster.c	2026-10-24 16:33:07.877714441 +0000
@@ -970,6 +970,19 @@
 				     0);
 			if (tbp == NULL)
 				break;
+			/*
+			 * DF-2725: admit components by their ACTUAL page
+			 * count (a mid-page-crossing component costs one
+			 * more page than round_page(blksize) suggests).
+			 * Mirrors cluster_wbuild's accounting; without it
+			 * a non-page-tiling geometry overflows the pbuf's
+			 * embedded xio_pages[] array.
+			 */
+			if (tbp->b_xio.xio_npages + bp->b_xio.xio_npages >
+			    maxiosize / PAGE_SIZE) {
+				bqrelse(tbp);
+				break;
+			}
 			for (j = 0; j < tbp->b_xio.xio_npages; j++) {
 				if (tbp->b_xio.xio_pages[j]->valid)
 					break;