⬢ DragonFlyBSD Kernel Audit
DF-5475 / fix.diff
← back to finding ↓ download raw
--- a/sys/cpu/x86_64/misc/x86_64-gdbstub.c
+++ b/sys/cpu/x86_64/misc/x86_64-gdbstub.c
@@ -475,6 +475,18 @@
   };
   struct x86_64regs registers;
 
+  /*
+   * DF-5475: If no gdb console was ever attached (gdb_tab == NULL) we
+   * cannot speak the remote serial protocol at all.  putpacket()'s ack
+   * wait (and getpacket()'s '$' wait) would spin forever on the
+   * getDebugChar() == -1 sentinel (& 0x7f -> 0x7f), or fault on the
+   * unchecked inlined gdb_tab dereferences, while the other CPUs sit
+   * IPI-stopped -- a permanent hang with no output.  Return and let
+   * the trap path resume (or the pending panic/dump proceed) instead.
+   */
+  if (gdb_tab == NULL)
+    return;
+
   registers.rax = raw_regs->tf_rax;
   registers.rbx = raw_regs->tf_rbx;
   registers.rcx = raw_regs->tf_rcx;