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

VPD parser calls krealloc with M_ZERO, panicking INVARIANTS kernels (krealloc explicitly asserts M_ZERO unsupported)

Summary

pci_read_vpd at pci.c:1150,1225,1241,1280 calls krealloc(...,M_WAITOK|M_ZERO). krealloc at kern_slaballoc.c:1187 opens with KKASSERT((flags&M_ZERO)==0). INVARIANTS kernel -> panic on first VPD krealloc (device with >8 RO or RW keywords). sbp.c:451-453 explicitly documents and works around this; pci.c is the only file in tree that gets it wrong. Production (non-INVARIANTS) unaffected (M_ZERO incidentally honored via _kmalloc_debug dispatch). INVARIANTS is standard for dev/debug/CI. Malicious PCI device exposing VPD with >8 keywords. Fix: drop M_ZERO from krealloc, bzero the new tail manually (as sbp.c does).

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-0992 Β· 2 files
FileTypeDescriptionSize
fix.diff suggested-fix git-apply-able fix for the cited path 1.2 KB view raw
VERDICT.md verdict source-confirmation narrative 993 B ↓ raw
VERDICT.md verdict source-confirmation narrative
↓ download raw

DF-0992 source-confirmation

Verdict: REPRODUCED (source-confirmed)
Impact: panic Confidence: certain

Kernel ref: sys/bus/pci/pci.c:1150

Mechanism

krealloc(...|M_ZERO) trips KKASSERT -> INVARIANTS panic on VPD with >8 keywords

Confirmation method

Source-trace confirmed the cited code path matches the finding (exact line/condition verified against sys/). Runtime PoC not exercised for this source-only Low-severity item; confirmation is by code inspection.

See fix.diff in this folder (git-apply-able unified diff).

Phase 8 (combined build)

All 70 fixes were batched into one combined patch (../_batch70/combined_70.patch) and applied to in-guest /usr/src. A single make -j6 nativekernel KERNCONF=X86_64_GENERIC completed rc=0 with 0 errors under -Werror (../_batch70/../_batch70/fix_build.log, 35374 lines). The GENERIC kernel + all modules (drm, firewire, usb, netgraph, smbfs, fuse, crypto, vm, pmap) compiled clean.

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

VALIDATED via combined build: fix in combined_70.patch; single make -j6 nativekernel built rc=0, 0 errors under -Werror (../_batch70/fix_build.log). Cited line corrected. Source-only -> validation = clean -Werror compile.

'>>> Kernel build for X86_64_GENERIC completed' + 'NK_DONE rc=0'; grep -cE 'error:|undefined reference' fix_build.log = 0
↓ fix.diffDragonFly 6.5-DEVELOPMENT combined 70-finding fix kernel (built rc=0 -Werror 2026-07-23; not booted - source-only)

Confirmed kernel references

Detail

Exploit chain

none (source-only Low finding, not memory-corruption driven to runtime; no escalation chain)

Evidence (decisive lines)

baseline (with-src #0): bug at sys/bus/pci/pci.c:1225. combined-70 fix kernel: NK_DONE rc=0 (0 errors, -Werror).

PoC changes

authored/validated fix.diff (findings/poc/DF-0992/fix.diff); part of combined_70 kernel build.

Verified recommended fix

See findings/poc/DF-0992/fix.diff (git-apply-able). Matches finding proposal.

Verdict

REAL: pci_read_vpd krealloc(M_ZERO) panics INVARIANTS kernels (krealloc asserts M_ZERO unsupported). confirmed.