# DF-3145 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

## Bottom line

50 failed mounts of the crafted HPFS image (sp_cpinum=0x4000 so hpm_cpdblk = 16384 * sizeof(struct cpdblk), sp_cpi far past EOF so the first bread fails and hpfs_cpinit returns at hpfs_subr.c:286 without freeing) grew the M_HPFSMNT malloc zone from empty to 106M in-use with 200 allocations and zero frees - about 2MiB of cpdblk leaked per failed mount (plus the separately-known hpmp mount-failure leak, DF-0889 family). Caller cleanup only frees hpm_bitmap/hpm_bmind via hpfs_bmdeinit, never cpdblk. Privileged mount trigger; resource exhaustion only. Fix frees cpdblk on both error paths; compile-validated.

## Kernel references
- sys/vfs/hpfs/hpfs_subr.c:276
- sys/vfs/hpfs/hpfs_subr.c:283-286
- sys/vfs/hpfs/hpfs_subr.c:298-300

## Exploit chain
(none: availability/correctness finding; no privilege chain)

## Fix

kfree hpm_cpdblk on both error returns

See fix.diff in this directory (git-apply-able against the read-only sys/
tree; applied only inside the disposable verification guest).

## Reproduction

build: host: python3 craft_hpfs_err.py out.img

run: guest: vnconfig -c -S 8m /dev/vn1 img; loop 50x mount_hpfs -o ro /dev/vn1 /mnt; vmstat -m | grep HPFS

expected: M_HPFSMNT grows ~2MiB per failed mount with no frees

## Notes on the PoC (what changed vs the finding sketch)

image adapted from the DF-3144 rig with sp_cpi = 0x40000 (bread fails immediately) instead of the livelock shape

## 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.
