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

virtio_balloon: inverted bounds KASSERT in vtballoon_update_stat disables defense-in-depth check

Summary

vtballoon_update_stat at line 474: KASSERT(idx >= VTBALLOON_S_NR, ...) is inverted - KASSERT panics when expression FALSE so panics for valid idx 0..9 and only passes OOB idx>=10. Guard should be idx < VTBALLOON_S_NR. Callers produce idx in [0,8) so no OOB write today. Defense-in-depth check silently absent. INVARIANTS kernel panics on first stat write. Fix: invert comparison.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-1705 Β· 2 files
FileTypeDescriptionSize
fix.diff suggested-fix Invert comparison to KASSERT(idx < VTBALLOON_S_NR). 614 B view raw
VERDICT.md verdict full analysis 1.1 KB ↓ raw
VERDICT.md verdict full analysis
↓ download raw

DF-1705 β€” 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:474.

Mechanism

vtballoon_update_stat KASSERT(idx >= VTBALLOON_S_NR) is inverted: panics for valid idx 0..8, passes OOB idx>=10. Currently dormant (stats path #if 0'd) but would panic on INVARIANTS kernel if re-enabled.

Fix

Invert comparison to KASSERT(idx < VTBALLOON_S_NR).

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:474. Fix compiled clean.

PoC changes

authored fix.diff: invert to KASSERT(idx < VTBALLOON_S_NR)

Verified recommended fix

Invert KASSERT comparison. Matches finding proposal.

Verdict

REPRODUCED (source-only). Inverted KASSERT(idx >= VTBALLOON_S_NR) panics for valid idx, passes OOB. Dormant (#if 0 priming) but INVARIANTS panic if re-enabled.