DragonFlyBSD Kernel Audit
DF-0183 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/kern/imgact_resident.c b/sys/kern/imgact_resident.c
--- a/sys/kern/imgact_resident.c
+++ b/sys/kern/imgact_resident.c
@@ -289,9 +289,10 @@
 	     * Check race against exec
 	     */
 	    if (vmres->vr_refs) {
-		lockmgr(&exec_list_lock, LK_RELEASE);
+		/* Hold the exclusive lock across the sleep so a concurrent
+		 * unregister cannot free vmres out from under us.  Use a
+		 * short timeout so we make forward progress. */
 		tsleep(vmres, 0, "vmres", 1);
-		lockmgr(&exec_list_lock, LK_EXCLUSIVE);
 		goto restart;
 	    }