β¬’ DragonFlyBSD Kernel Audit
← triage Β· dashboard
DF-5204

Terminal-emulator registry sc_term_list is completely unsynchronized and the SCTERM_MODULE MOD_UNLOAD refcount gate is TOCTOU β€” kldload/kldunload of any third-party scterm module races console ioctls into list corruption or a call into freed module text

Summary

add/remove mutate the global list with no lock while the two match walks run under inconsistent tokens (syscons_lock vs vga_token) and the unload EBUSY gate is non-atomic with the te_init refcount acquisition. Latent in-tree (both emulators static, no loadable scterm modules exist) - an API hazard for third-party module authors, root-gated. Dedicated-spinlock + atomic-gate fix.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-5204 Β· 1 files
FileTypeDescriptionSize
verdict.json file 1.2 KB view raw

Fix verification

not_testable
baseline no→ patch + rebuild →patched clean
per-fix-DF-5204

Confirmed kernel references

Detail

Evidence (decisive lines)

static analysis: unlocked scterm.c:74-89 vs token-held walks at syscons.c:1584/1604

Verified recommended fix

dedicated spinlock around sc_term_list + atomic unload gate

Verdict

untested (latent: no loadable scterm modules exist in-tree; root-gated third-party setup)