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

FD_FORM formats with unbounded attacker nsecs over-reading fd_formb heap buffer via DMA/PIO

Summary

FD_FORM/FD_FORMAT path derives transfer byte count as sizeof(struct fd_idfield_data)*finfo->fd_formb_nsecs without clamping nsecs to FD_MAX_NSEC(36). Valid idfield region only 36*4=144 bytes past format header but nsecs is u_char verbatim from caller so DMA/PIO transfer can be sized up to 1020 bytes from 164-byte heap object. fdstate isa_dmastart/isa_dmabp uses bp->b_data+fd->skip format?bp->b_bcount:fdblk. PCMCIA FDC_NODMA fdcpio write branch bus_space_write_multi_1 reads ENTIRE count unconditionally. nsecs=255 reads 876 bytes past end. Contents written onto floppy as sector-ID data root reads back to recover kernel heap info disclosure. Requires root FD_FORM FWRITE. Full leak on YE Data PCMCIA FDC_NODMA. [VERIFIED pass2: reproduced - nsecs 255 moves 1020 bytes with first OOB byte exactly at legal 144 and 876 heap canary bytes captured at the FDC port; nsecs clamp fix-validated]

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-2456 Β· 10 files
FileTypeDescriptionSize
README.md β€” 330 B ↓ raw
VERDICT.md β€” 1.4 KB ↓ raw
build.sh β€” 89 B view raw
dfhw.c β€” 29.3 KB view raw
env.txt β€” 254 B view raw
fix.diff β€” 479 B view raw
manifest.json β€” 721 B view raw
run.log β€” 902 B view raw
run.sh β€” 135 B view raw
verdict.json β€” 2.0 KB view raw

DF-2456 -- evidence pack

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

Build: see build.sh (dfhw.ko verbatim fd) Run: sysctl "kern.dfhwgo=fd_form 255" (control: fd_form 36)

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-2456 VERDICT

Status: reproduced Impact: none Confidence: certain

Production fdcpio moved 1020 bytes for FD_FORMAT with nsecs=255 (b_bcount = 4*255 computed at fdformat:2272 with no clamp to FD_MAX_NSEC=36): the first 144 bytes are the legal idfields region; the remaining 876 bytes were read from past the fd_formb heap object (kmalloc canary 0x66 delivered to the FDC data port starting exactly at stream index 144). Control nsecs=36 moved exactly 144 bytes with 0 past the object. The bytes are captured byte-by-byte at the emulated FDC data port - on the FDC_NODMA (YE PCMCIA) path they are physically transmitted; the read-back channel makes this a heap info-disclosure.

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

requires a floppy controller (FDC_NODMA path fully emulated; DMA path equivalent via isa_dmastart)

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-2456

Confirmed kernel references

Detail

Exploit chain

root FD_FORM(FWRITE) ioctl with nsecs up to 255 -> up to 876 bytes past the formb object streamed to the floppy as sector-ID data -> read the disk back to recover kernel heap contents

Evidence (decisive lines)

run.log (moved=1020, canary captured from index 144; control 144/0)

PoC changes

verbatim fd.c compiled into the rig (symbol renames only); production fdcpio transfer call with the production skip/bcount computation

Verified recommended fix

clamp: if (finfo->fd_formb_nsecs == 0 || finfo->fd_formb_nsecs > FD_MAX_NSEC) return EINVAL; in the FD_FORM path

Verdict

Production fdcpio moved 1020 bytes for FD_FORMAT with nsecs=255 (b_bcount = 4*255 computed at fdformat:2272 with no clamp to FD_MAX_NSEC=36): the first 144 bytes are the legal idfields region; the remaining 876 bytes were read from past the fd_formb heap object (kmalloc canary 0x66 delivered to the FDC data port starting exactly at stream index 144). Control nsecs=36 moved exactly 144 bytes with 0 past the object. The bytes are captured byte-by-byte at the emulated FDC data port - on the FDC_NODMA (YE PCMCIA) path they are physically transmitted; the read-back channel makes this a heap info-disclosure.