Page MenuHomeFreeBSD

kern_reboot(): don't clear kdb_active
ClosedPublic

Authored by mhorne on Nov 20 2023, 6:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
May 8 2024, 7:15 AM
Unknown Object (File)
May 8 2024, 7:15 AM
Unknown Object (File)
May 8 2024, 4:25 AM
Unknown Object (File)
Jan 7 2024, 2:34 PM
Unknown Object (File)
Dec 31 2023, 6:47 AM
Unknown Object (File)
Dec 31 2023, 6:46 AM
Unknown Object (File)
Dec 31 2023, 6:45 AM
Unknown Object (File)
Dec 28 2023, 12:07 AM
Subscribers
None

Details

Summary

It is possible to reach this function from ddb via the "reset" command.
When this happens, we don't actually exit kdb, meaning we never execute
the latter steps of kdb_break() to restore the system state (e.g.
re-enable scheduler).

Therefore, we should not clear the kdb_active flag in this function, as
the debugger is still active. Put differently, kern_reboot() is not an
authority on kdb state, and should not touch it. The original motivation
for this assignment is not clear; I have checked thoroughly and I am
convinced it is not required by any reset code.

This fixes an edge case where a panic can be triggered during reset from
ddb:

  1. Enter ddb via keyboard break sequence (KERNEL_PANICKED() == false && td->td_critnest > 0)
  2. Execute the "reset" command
  3. kern_reboot() sets kdb_active = false
  4. A witness_checkorder() call via shutdown handler sees !kdb_active and panics

This is my preferred alternative to the initial fix I proposed in D38656.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable