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

XPT_DEV_MATCH cookie fields are user-controlled kernel pointers blindly dereferenced (arbitrary kread / panic)

Summary

xptedtmatch at cam_xpt.c:2444-2446: if generation=0 bypasses gen check, cdm->pos.cookie.bus (user-controlled cam_eb* kernel pointer) passed verbatim to xptbustraverse at :2631 which derefs TAILQ_NEXT(bus,links) and bus->sim. Same for cookie.target/device/periph (xpttargettraverse :2192, xptdevicetraverse :2228, xptperiphtraverse :2349). ccb_dev_match stays in user memory (cam_periph_mapmem only bounces patterns/matches arrays). Root-only (/dev/xpt0 mode 0600). Arbitrary kernel VA read via observing matches[] field values copied from wild pointer; low value (0x1000) panics. Powerful primitive: ~256B per device match leaked (inq_data, sim fields). Fix: copyin entire ccb_dev_match or validate cookies against live EDT via TAILQ_FOREACH.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

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

DF-0975 source-confirmation

Verdict: REPRODUCED (source-confirmed)
Impact: leak Confidence: likely

Kernel ref: sys/bus/cam/cam_xpt.c:2446

Mechanism

XPT_DEV_MATCH cookie fields are user-controlled kernel pointers deref'd (root-only)

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/cam/cam_xpt.c:2444. combined-70 fix kernel: NK_DONE rc=0 (0 errors, -Werror).

PoC changes

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

Verified recommended fix

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

Verdict

REAL: XPT_DEV_MATCH trusts user cookie fields as kernel pointers (generation=0 bypass) deref'd in xpt*traverse. root-only (/dev/xpt0 0600). confirmed.