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

ext2_reallocblks feeds unclamped attacker-controlled pref (crafted i_db[]/indirect values via ext2_blkpref) into dtog() as the cg index β€” OOB heap reads of e2fs_gd[]/e2fs_maxcluster[]/e2fs_clustersum[] and wild device I/O (root-sysctl-gated)

Summary

ext2_blkpref returns raw le32toh(bap[tmp]) values from crafted on-disk block maps (:710-712). Every other consumer funnels them through ext2_alloc's 'bpref >= bcount -> 0' clamp (:130), but ext2_reallocblks:302 calls ext2_hashalloc(ip, dtog(fs, pref), pref, ...) directly: pref up to 0xFFFFFFFF gives cg up to ~524287, far beyond gcount, indexing fs->e2fs_maxcluster[cg] (:1146), fs->e2fs_gd[cg] (:1151) and fs->e2fs_clustersum[cg] out of bounds - wild kernel heap reads whose results then steer bread/bdwrite device offsets. Gated behind vfs.ext2fs.doreallocblks != 0 (default 0, root-writable sysctl) and contigsumsize > 0, hence Low. Verification skipped (privileged-configuration gate). Fix: clamp pref >= bcount -> 0 (mirroring :130). [VERIFIED pass2: vn dscheck rejects negative device offsets before reallocblks consumes pref - OOB index unobservable via this route; sysctl gate default-0 confirmed]

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-3065 Β· 7 files
FileTypeDescriptionSize
README.md β€” 301 B ↓ raw
VERDICT.md β€” 1.3 KB ↓ raw
env.txt β€” 248 B view raw
fix.diff β€” 105 B view raw
manifest.json β€” 564 B view raw
run.log β€” 244 B view raw
verdict.json β€” 1.4 KB view raw

DF-3065 - ext2_reallocblks feeds unclamped crafted pref into dtog() -> OOB reads of e2fs arrays

Severity Low | verdict: not_reproduced | impact: none

Reproduce

No runnable PoC on this rig (see VERDICT.md for why).

See VERDICT.md for the full narrative and run.log for the decisive output.

VERDICT.md
↓ download raw

DF-3065 verification

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

Attempted with the gate open: vfs.ext2fs.doreallocblks set to 1 (default 0, root-only sysctl confirmed), crafted ext2 image with i_block[0]=0xFFFFFFFF and i_block[1]=0x7FFFFFFF via debugfs. The wild block numbers short-circuit earlier: reads/writes of the crafted file fail with the vn driver rejecting negative device offsets (dscheck(vn2): negative bio_offset -1024 in dmesg; cat returns EINVAL, dd writes 0 bytes) before ext2_reallocblks consumes the garbage pref. The claimed OOB index of e2fs_maxcluster/e2fs_gd could not be observed; the root-sysctl gate (default off) plus this early rejection keep it unreachable from the crafted-image route on this rig.

Kernel references

Fix

See fix.diff.

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

Confirmed kernel references

Detail

Evidence (decisive lines)

VERDICT.md + run.log + sources

PoC changes

none

Verified recommended fix

diff: clamp pref in ext2_reallocblks exactly like ext2_alloc:130 (bpref >= bcount -> 0) before dtog().

Verdict

Attempted with the gate open: vfs.ext2fs.doreallocblks set to 1 (default 0, root-only sysctl confirmed), crafted ext2 image with i_block[0]=0xFFFFFFFF and i_block[1]=0x7FFFFFFF via debugfs. The wild block numbers short-circuit earlier: reads/writes of the crafted file fail with the vn driver rejecting negative device offsets (dscheck(vn2): negative bio_offset -1024 in dmesg; cat returns EINVAL, dd writes 0 bytes) before ext2_reallocblks consumes the garbage pref. The claimed OOB index of e2fs_maxcluster/e2fs_gd could not be observed; the root-sysctl gate (default off) plus this early rejection keep it unreachable from the crafted-image route on this rig.