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

virtio_balloon: vtballoon_update_stats called from kthread without the serializer it requires

Summary

vtballoon_update_stats opens with ASSERT_SERIALIZED(VTBALLOON_SLZ(sc)) at 551 and shares stats vq with vtballoon_stats_vq_intr (dequeues under serializer at 581-594). Sole live caller vtballoon_thread at 868 invokes WITHOUT acquiring sc->vtballoon_slz - thread drops serializer via vtballoon_sleep (840) before calling. Comment at 346 documents dev hit this panic and worked around by #if 0 priming at 346-354. Stats path dormant because priming disabled. Re-enabling: INVARIANTS panic immediately; production: unsynchronized virtqueue_enqueue (566) vs virtqueue_dequeue (593) corrupts vq_desc_head_idx/vq_free_cnt/vq_descx. Fix: VTBALLOON_ENTER/EXIT_SLZ around 868.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-1706 Β· 2 files
FileTypeDescriptionSize
fix.diff suggested-fix Acquire VTBALLOON_SLZ around vtballoon_update_stats call in the thread. 450 B view raw
VERDICT.md verdict full analysis 1.2 KB ↓ raw
VERDICT.md verdict full analysis
↓ download raw

DF-1706 β€” Verdict

Severity: Low Status: REPRODUCED (source-only confirmation β€” driver/HW-gated, not runtime-triggered on QEMU guest) Impact: panic Confidence: certain

Verdict

REPRODUCED. The cited bug is confirmed real in the audited source at sys/dev/virtual/virtio/balloon/virtio_balloon.c:551,868.

Mechanism

vtballoon_update_stats asserts ASSERT_SERIALIZED but the sole live caller (vtballoon_thread:868) invokes without acquiring the serializer. Dormant (priming disabled) but would corrupt vq state or panic on INVARIANTS if re-enabled.

Fix

Acquire VTBALLOON_SLZ around vtballoon_update_stats call in the thread.

The full git-apply-able diff is in fix.diff.

Build validation

fix.diff applies cleanly and compiles with -Werror as part of the batch module build (all 51 fixes applied to /usr/src, kernel+modules built).

Notes

Source-only confirmation: this finding is in a device driver code path that requires specific hardware not present in the QEMU guest. The bug is confirmed by source tracing (cited path:line verified against sys/), and the fix compiles clean. No runtime trigger was attempted as the relevant device/module is HW-gated.

Fix verification

fixed
baseline no→ patch + rebuild →patched clean

VALIDATED via batch build rc=0.

virtio_balloon.ko built with -Werror.
↓ fix.diffDragonFly 6.5-DEVELOPMENT #0: Thu Jul 2 06:02:54 UTC 2026

Confirmed kernel references

Detail

Exploit chain

none

Evidence (decisive lines)

Source traced at sys/dev/virtual/virtio/balloon/virtio_balloon.c:551,868. Fix compiled clean.

PoC changes

authored fix.diff: VTBALLOON_ENTER/EXIT_SLZ around update_stats call

Verified recommended fix

Acquire serializer around vtballoon_update_stats in thread. Matches finding proposal.

Verdict

REPRODUCED (source-only). vtballoon_update_stats requires serializer but thread calls without acquiring it. Dormant but corrupts vq state or INVARIANTS panic if re-enabled.