⬢ DragonFlyBSD Kernel Audit
DF-2890 / fix.diff
← back to finding ↓ download raw
--- a/sys/vm/vm_contig.c
+++ b/sys/vm/vm_contig.c
@@ -191,7 +191,7 @@
 		/*
 		 * We've successfully busied the page
 		 */
-		if (m->queue - m->pc != queue) {
+		if (m->queue != queue) {
 			vm_page_wakeup(m);
 			continue;
 		}
@@ -374,7 +374,9 @@
 		 *
 		 * (still in critical section)
 		 */
-		for (i = start + 1; i < (start + size / PAGE_SIZE); i++) {
+		for (i = start + 1;
+		     i < (start + size / PAGE_SIZE) && i < vmstats.v_page_count;
+		     i++) {
 			m = &pga[i];
 			pqtype = m->queue - m->pc;
 			if ((VM_PAGE_TO_PHYS(&m[0]) !=
@@ -395,7 +397,9 @@
 		 *
 		 * (still in critical section)
 		 */
-		for (i = start; i < (start + size / PAGE_SIZE); i++) {
+		for (i = start;
+		     i < (start + size / PAGE_SIZE) && i < vmstats.v_page_count;
+		     i++) {
 			m = &pga[i];
 
 			if (vm_page_busy_try(m, TRUE)) {