Issue #3496 has been reported by sigttou.
----------------------------------------
Bug #3496: syscons: kernel panic in scclose() when the controlling process of a
vty dies during a pending VT switch
http://bugs.dragonflybsd.org/issues/3496
* Author: sigttou
* Status: New
* Priority: Normal
* Target version: 6.6
* Start date: 2026-12-04
----------------------------------------
@scclose()@ calls @finish_vt_rel(scp, TRUE)@ and @finish_vt_acq(scp)@ before it
takes @syscons_mtx@. With a vty in VT_PROCESS mode whose owner has not released
the screen (SWITCH_WAIT_REL set on sc->old_scp) and the owner dying,
@finish_vt_rel()@ switches to the new screen, and @exchange_scr()@ calls
@update_kbd_state()@ (for a K_XLATE vty also @save_kbd_state()@) with @unlock
!= 0@, which drop and re-acquire syscons_mtx around @kbd_ioctl()@. Unlocking a
mutex that was never taken panics:
panic: assertion "(nlock & MTX_MASK) != MTX_MASK" failed in _mtx_unlock at
kern_mutex.c:725
_mtx_unlock <- syscons_unlock <- update_kbd_state <- exchange_scr <-
do_switch_scr <- finish_vt_rel <- scclose <- devfs_spec_close <- ... <- fdfree
<- exit1 <- sigexit(sig 9)
Seen on a laptop (Intel GM965) when Xorg, blocked in the kernel by a display
freeze, was killed with SIGKILL after the user had pressed Ctrl+Alt+Fn: three
times in a row, each exit of X after a freeze. Reproduced deterministically in
a QEMU guest on master 175de3bdf7: a process sets VT_PROCESS on the active vty
and ignores the release signal, a switch away is requested from another
process, then the first process is killed with SIGKILL.
The VT_RELDISP and VT_SETMODE ioctl paths already hold syscons_mtx around
finish_vt_rel() and finish_vt_acq(). The patch takes the lock in scclose()
before them and keeps the existing locked section (one line moved). In the
guest: the reproducer no longer panics and the switch completes; 500 VT
switches between two vtys, a correct VT_RELDISP release followed by a normal
exit and followed by SIGKILL, and serial console login/logout show no failure.
Not tested: X, the DRM/KMS console, a framebuffer vty.
Reporter: @vjkarbo
---Files--------------------------------
0001-syscons-hold-syscons_mtx-when-scclose-finishes-a-pen.patch (2.08 KB)
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://bugs.dragonflybsd.org/my/account