⬢ DragonFlyBSD Kernel Audit
DF-3238 / fix.diff
← back to finding ↓ download raw
diff --git aa/sys/vfs/procfs/procfs_map.c b/procfs_map.c
index 81ccc4e..40782ab 100644
--- aa/sys/vfs/procfs/procfs_map.c
+++ b/procfs_map.c
@@ -233,9 +233,18 @@ procfs_domap(struct proc *curp, struct lwp *lp, struct pfsnode *pfs,
 			break;
 		}
 
+		/*
+		 * Revalidate the iteration point.  vm_map_lookup_entry()
+		 * sets *entry = NULL when no prior record exists (the whole
+		 * region at/below e_start was unmapped while we released
+		 * the map lock); RB_NEXT() would then dereference NULL, so
+		 * terminate the walk instead.
+		 */
 		if (last_timestamp != map->timestamp) {
 			vm_map_entry_t reentry;
 			vm_map_lookup_entry(map, e_start, &reentry);
+			if (reentry == NULL)
+				break;
 			entry = reentry;
 		}
 	}