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

Crafted HAMMER1 image with a CRC-corrupted root B-Tree node panics the stock INVARIANTS kernel at mount: panic assertion error == 0 failed in hammer_init_cursor at hammer_cursor.c:202, via sys_mount -> hammer_vfs_mount -> hammer_vfs_vget -> hammer_get_inode -> hammer_init_cursor. The commented-out cleanup line sits directly beneath the assertion, so on production kernels the same trigger returns with cursor->node NULL and cursor->ip refs and the inode sh-lock held, feeding the NULL-node cursor into btree_search (left_bound deref) for the twelve ignoring callers. Root-gated (mount of crafted image); availability only, no privilege gain.

## Kernel references
- sys/vfs/hammer/hammer_cursor.c:202
- sys/vfs/hammer/hammer_cursor.c:117-130
- sys/vfs/hammer/hammer_ondisk.c:1315-1333
- sys/vfs/hammer/hammer_inode.c:499

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

## Fix

hammer_init_cursor now unwinds via hammer_done_cursor and returns the error instead of asserting; combined-kernel A/B: mount of the same image returns clean EIO with no panic

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

## Reproduction

build: guest: cc -O -o corrupt_root corrupt_root.c; image: vnconfig -c -S 2g /dev/vn0 h1.img && newfs_hammer -f /dev/vn0 && vnconfig -u vn0 && ./corrupt_root h1.img

run: guest: vnconfig -c -S 2g /dev/vn0 h1.img && mount_hammer /dev/vn0 /mnt/h1

expected: panic: assertion error == 0 failed in hammer_init_cursor at hammer_cursor.c:202 (see panic.txt)

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

corrupt_root.c written from scratch: locates the root node by scanning for CRC-valid btree nodes whose parent offset is zero, then flips one byte so the stored CRC no longer matches

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