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

cv_destroy performs no waiters/queued-state validation β€” destroy-with-waiter goes undiagnosed, leaving a stale wchan in td_wchan (divergence from FreeBSD INVARIANTS probe)

Field Value
ID DF-2986
Status new
Severity Info
CVSS 3.1 CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:N/I:N/A:L
CWE CWE-667 (missing diagnostic assertion)
File sys/kern/kern_condvar.c
Lines 14-18
Area kern
Confidence certain
Discovered 2026-09-02
Pass 2 (GLM 5.3 second pass)
Bucket base:kern
Reported pending
Known CVE none
CVE match novel

Summary

cv_destroy only calls spin_uninit, which is a no-op. It carries no INVARIANTS-mode assertion that no thread is still blocked on β€” or interlocked-enqueued against β€” the cv being destroyed. FreeBSD's cv_destroy asserts under INVARIANTS that the associated sleep queue is empty. In the ~100 in-tree consumer files (several user-reachable: /dev/cuse, u4b, drm, ipmi, wlan scan), a destroy-with-live-waiter bug therefore produces no diagnostic at all: the waiter keeps the freed cv pointer as td_wchan, hangs silently (timo=0 cv_wait sleeps forever), and after KVA reuse the stale identity can cross-wake unrelated sleepers at the same address. No memory-safety impact today β€” _wakeup matches by pointer identity only and never dereferences, and spin_uninit writes nothing β€” a defense-in-depth/diagnostics divergence. Fix: INVARIANTS empty-check via a kern_synch helper probing gd_tsleep_hash (bare KASSERT(cv_waiters==0) is NOT correct β€” ghost counts from timeouts are legitimate).

Timeline

  • 2026-09-02 Discovered during pass-2 audit of kern_condvar.c (GLM 5.3). Protocol otherwise proven sound (interlock/latch/ghost accounting all killed with citations).

Discussion (0)

No comments yet.