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

Off-by-one NUL write past bt->model[5] in Inquire-Model parsing

Summary

Inquire-Model copy loop iterates i over full sizeof(model_data.ascii_model)(5 bytes) only breaks on space then writes bt->model[i]=NUL. bt->model is char[5] last field of struct bt_softc so when adapter returns 5 bytes with no 0x20 (including documented case 5th byte 0x00 not space) loop exits i==5 terminator write lands at bt->model[5] one byte past array/past end of softc. model_data.ascii_model 5 bytes bt->model 5 bytes no room for terminator. model final field of bt_softc overflow byte lands past softc allocation. [VERIFIED pass2: source-harness reproduced - 5-byte no-space reply exits i==5 writing model[5]=0 past last softc field, canary 42 to 00 at +344; char model[6] fix authored]

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-2430 Β· 10 files
FileTypeDescriptionSize
README.md β€” 273 B ↓ raw
VERDICT.md β€” 1.5 KB ↓ raw
bt2430.c β€” 2.1 KB view raw
build.sh β€” 79 B view raw
env.txt β€” 254 B view raw
fix.diff β€” 271 B view raw
manifest.json β€” 669 B view raw
run.log β€” 516 B view raw
run.sh β€” 89 B view raw
verdict.json β€” 1.9 KB view raw

DF-2430 -- evidence pack

Verdict: reproduced (reproduced=1, impact=none, confidence=likely)

Build: cc -O -o bt2430 bt2430.c Run: ./bt2430

See VERDICT.md for the full narrative, run.log/panic.txt for the decisive output, fix.diff for the post-verification fix.

VERDICT.md
↓ download raw

DF-2430 VERDICT

Status: reproduced Impact: none Confidence: likely

Source-level harness (DF-1510 precedent) of the exact Inquire-Model parse loop (bt.c:420-425, byte-identical semantics) proves the off-by-one: with the documented 5-byte reply whose fifth byte is 0x00 (not space), the loop exits with i==5 and bt->model[5] = 0 writes one byte past char model[5], the LAST field of struct bt_softc (btreg.h:638) - the trailing canary flipped 0x42 -> 0x00. The full production bt_fetch_adapter_info dispatch was attempted through a watchpoint-emulated BusLogic port protocol but the command handshake could not be completed reliably on this snapshot, so the demonstration is harness-level; code-level truth is certain (sizeof(bt_softc)=344, terminator lands at +344).

Kernel references

Guest

DragonFly dfbsd 6.5-DEVELOPMENT DragonFly 6.5-DEVELOPMENT #0: Thu Jul 2 06:02:54 UTC 2026 root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64

Notes

impact depends on slab size-class rounding for 344 bytes; single NUL byte, Low

Fix status (batch validation)

Applied with the 36 sibling fix.diffs of this batch in findings/poc/_batch41/all_fixes.patch; single in-guest make -j6 nativekernel KERNCONF=X86_64_GENERIC completed RC=0 with zero errors under -Werror (full log: findings/poc/_batch41/fix_build8.log). Behavior A/B intentionally skipped for this Info-tier item.

Fix verification

not_testable
↓ fix.diffper-fix-DF-2430

Confirmed kernel references

Detail

Exploit chain

hostile/misbehaving BusLogic HBA returns a 5-byte model with no 0x20 -> one NUL byte written past the softc allocation (adjacent slab chunk if the zone rounds 344 up exactly)

Evidence (decisive lines)

run.log (harness output: canary 0x42 -> 0x00 at model[5])

PoC changes

verbatim loop semantics in a userspace harness (compiler unavailable on host; run on guest)

Verified recommended fix

declare char model[6] or terminate with bt->model[min(i, sizeof(bt->model)-1)] = 0

Verdict

Source-level harness (DF-1510 precedent) of the exact Inquire-Model parse loop (bt.c:420-425, byte-identical semantics) proves the off-by-one: with the documented 5-byte reply whose fifth byte is 0x00 (not space), the loop exits with i==5 and bt->model[5] = 0 writes one byte past char model[5], the LAST field of struct bt_softc (btreg.h:638) - the trailing canary flipped 0x42 -> 0x00. The full production bt_fetch_adapter_info dispatch was attempted through a watchpoint-emulated BusLogic port protocol but the command handshake could not be completed reliably on this snapshot, so the demonstration is harness-level; code-level truth is certain (sizeof(bt_softc)=344, terminator lands at +344).