⬢ DragonFlyBSD Kernel Audit
DF-5815 / fix.diff
← back to finding ↓ download raw
--- a/sys/vm/vm_pageout.c	2026-10-13 03:47:49.422426023 +0000
+++ b/sys/vm/vm_pageout.c	2026-10-13 03:50:15.896514129 +0000
@@ -825,6 +825,15 @@
 	 * allow the per-queue max_launder to increase up to a maximum of
 	 * vm_max_launder / 16.
 	 */
+	/*
+	 * Sanity clamp: vm_max_launder is a root-writable sysctl with no
+	 * range validation.  A negative value would otherwise leak through
+	 * the cap below as a negative per-queue launder budget, permanently
+	 * disabling dirty-page laundering and livelocking the pagedaemon.
+	 */
+	if (vm_max_launder < 0)
+		vm_max_launder = 0;
+
 	max_launder = (long)vm_max_launder / PQ_L2_SIZE;
 	if (pass)
 		max_launder *= 2;
@@ -832,7 +841,7 @@
 
 	if (max_launder <= 1)
 		max_launder = 1;
-	if (max_launder >= vm_max_launder / 16)
+	if (vm_max_launder / 16 > max_launder)
 		max_launder = vm_max_launder / 16 + 1;
 
 	/*