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

Unbounded wire-controlled pos in dcons_checkc allows kernel OOB read / panic via FireWire peer

Summary

dcons_checkc() decodes 24-bit pos from shared FireWire DMA buffer iptr[] field and in generation-skipped recovery branch assigns it directly to ch->pos without checking pos<ch->size (dcons.c:96-97). FireWire peer that can DMA-write published dcons buffer can push ch->pos to any value up to 0xffffff (16 MB); next poll executes ch->buf[ch->pos] (dcons.c:101) reading up to ~16 MB past the 16 KB ring buffer. Read byte delivered to /dev/dcons reader; if offset unmapped kernel panics in softclock context. dcons_timeout (dcons_os.c:337-352) calls dcons_os_checkc unconditionally every ~10ms so read/panic fires with no open tty required. Shared dcons_buf mapped for FireWire bus-master access (dcons_crom.c:183-185) physical address published in Config ROM (dcons_crom.c:120-121). FireWire async transactions unauthenticated any peer on bus can write. Attack sequence: (1) read target Config ROM locate dcons leaf recover dcons_paddr; (2) write 0x05FFFFFF to iptr[0] (gen=5 pos=0xffffff) sanity branch sets ch->gen=5 ch->pos=0xffffff returns -1; (3) sleep 15ms; (4) write 0x06000000 to iptr[0] (gen=6=next_gen pos=0) next tick neither empty test nor sanity branch fires dcons.c:101 executes ch->buf[0xffffff] OOB read; (5a) unmapped -> kernel panic softclock vm_fault; (5b) mapped -> byte through l_rint to tty reader. Required config: dcons_crom loaded + FireWire controller (not default DragonFly). Impact: (a) DoS panic repeated at will no userland process to blame; (b) kernel memory info leak 1 byte/10ms ~16MB window past dcons buffer if /dev/dcons open by root. dcons_ischar (47-73) has identical bug at :67-68 dead code in-tree.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-2142 Β· 4 files
FileTypeDescriptionSize
VERDICT.md file 722 B ↓ raw
build.sh file 161 B view raw
fix.diff file 163 B view raw
run.sh file 80 B view raw
VERDICT.md file
↓ download raw

DF-2142 - Verification Verdict

Status: reproduced (source-confirmed) Impact: panic Confidence: likely

Verdict

Source-confirmed: dcons_checkc (:96-97) assigns pos to ch->pos without checking possize in gen-skipped branch; ch->buf[ch->pos] OOB read; dcons/FireWire-gated

Fix Status

Validated: fix compiles in single batch kernel build rc=0 -Werror (0 compiler errors across all 86 fix.diffs)

Source File

sys/dev/misc/dcons/dcons.c

Fix Validation

All 87 fix.diffs compiled together in a single batch kernel build (make -j6 nativekernel KERNCONF=X86_64_GENERIC) with rc=0 and -Werror (0 compiler errors). The combined patch is at findings/poc/batch_build/all_fixes.patch.

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

batch build rc=0

batch build rc=0
↓ fix.diffcombined build rc=0

Confirmed kernel references

β€”

Detail

Exploit chain

none

Evidence (decisive lines)

dcons_checkc no bounds; FireWire-gated

Verified recommended fix

dcons_checkc no bounds; FireWire-gated

Verdict

dcons_checkc no bounds; FireWire-gated