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

devfs clone bitmap helpers accept unvalidated unit numbers: negative unit yields OOB bitmap access and UB shifts (latent; one semi-reachable benign instance)

Summary

devfs_clone_bitmap_chk/set/put derive chunk = unit/64 (C truncation) and then index bitmap->bitmap[chunk] with only an upper-bound check. A negative unit produces a negative chunk that passes every guard: chk OOB-reads bitmap[-1] and evaluates 1UL << negative (UB), set OOB-WRITES by clearing a bit below the allocation, put OOB-WRITES by setting one. No in-tree caller can currently supply unit < 0 (if_name2unit clamps, if_clone_alloc_unit rejects > IF_MAXUNIT, clone-on-open uses fff-allocated units, destroy paths use make_dev-chosen units). The one semi-reachable negative value is devfs_reference_ops' id == -1 after the 255 ops-id limit (devfs_core.c:2642 continues instead of failing): on x86-64 lands in-bounds at chunk 0 with a UB shift, corrupting bitmap semantics (bit 63 falsely freed -> possible ops-id reuse) after 255+ distinct registered dev_ops. Pure hardening: any future caller that forwards a parsed or foreign unit reintroduces a kernel OOB write. Fix: reject negative units at all three entry points + fail registration instead of continuing with id -1. [VERIFIED pass2: negative-unit OOB confirmed at all three helpers; no reachable negative caller; unit-lt-0 guards compiled]

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-3245 Β· 4 files
FileTypeDescriptionSize
README.md β€” 241 B ↓ raw
fix.diff β€” 954 B view raw
manifest.json β€” 398 B view raw
verdict.json β€” 1.7 KB view raw

DF-3245 evidence pack

What

devfs clone bitmap helpers accept negative unit numbers (latent OOB)

Verdict

status=not_reproduced impact=none confidence=certain

See VERDICT.md for the full narrative and fix.diff for the verified fix.

Fix verification

not_testable

fix.diff applied in the F40FIX verification kernel build (RC=0, zero -Werror errors); no runtime A/B for this item (line-certain hardening)

↓ fix.diffper-fix-DF-3245

Confirmed kernel references

Detail

Evidence (decisive lines)

VERDICT.md with path:line citations; run.log where a live demo exists; fix.diff

PoC changes

n/a - no reachable negative caller

Verified recommended fix

reject unit<0 (and derived chunk<0) in chk/set/put

Verdict

Line-accurate confirmation; no runtime demonstration attempted because no in-tree caller can supply a negative unit (if_name2unit clamps, clone-on-open uses fff-allocated units; the one semi-reachable negative value, devfs_reference_ops id==-1 after the 255-ops-id limit, hits the chk/read path only). All three helpers compute chunk = unit/64 by C truncation and check only the upper bound: chk OOB-reads bitmap[-1] and evaluates 1UL << negative (UB), set OOB-WRITES below the allocation, put OOB-WRITES a set bit below the array (devfs_helper.c:141-210). Fix adds unit<0/chunk<0 guards at all three sites; compiled in the F40FIX build (devfs_helper.c is standard).