⬢ DragonFlyBSD Kernel Audit
DF-5561 / fix.diff
← back to finding ↓ download raw
--- a/sys/platform/pc64/x86_64/db_interface.c
+++ b/sys/platform/pc64/x86_64/db_interface.c
@@ -167,7 +167,16 @@
 	db_printf(" stopped\n");
 
 	setjmp(db_global_jmpbuf);
 	db_global_jmpbuf_valid = TRUE;
-	db_active++;
+	/*
+	 * DF-5561: count only the first entry.  A nested trap taken while
+	 * this session is live longjmps back to the setjmp above and would
+	 * re-execute the increment, while the abandoned outer invocation's
+	 * db_active-- never runs: db_active would leak nonzero forever and
+	 * trap() would then route *every* trap (including ordinary user
+	 * page faults) into trap_fatal()/kdb_trap(), wedging the machine.
+	 */
+	if (db_active == 0)
+		db_active++;
 	/* vcons_set_mode(1); */
 	if (ddb_mode) {
 	    cndbctl(TRUE);