⬢ DragonFlyBSD Kernel Audit
DF-4852 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/disk/dm/striped/dm_target_striped.c	2026-09-24 14:13:44.057774323 +0000
+++ b/sys/dev/disk/dm/striped/dm_target_striped.c	2026-09-24 14:13:44.073774116 +0000
@@ -96,7 +96,14 @@
 	}
 
 	chunksize = atoi64(argv[1]);
-	if (chunksize < 1 || chunksize * DEV_BSIZE > MAXPHYS) {
+	/*
+	 * Cast to 64-bit BEFORE multiplying: the int*int product overflows
+	 * for chunksize >= 2^22 (4194304*512 == 2^31 wraps negative) and
+	 * the guard silently accepts chunk sizes up to INT_MAX blocks
+	 * (DF-4852).  The intended cap is MAXPHYS/DEV_BSIZE == 256 blocks.
+	 */
+	if (chunksize < 1 ||
+	    (uintmax_t)chunksize * DEV_BSIZE > MAXPHYS) {
 		kprintf("dm: Error unsupported chunk size %jdKB\n",
 			(intmax_t)chunksize * DEV_BSIZE / 1024);
 		return EINVAL;