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

Code-proven and not injectable: for PFSTATE_STACK_GLOBAL states (every RDR translation) pf_state_key_attach holds pf_global_statetbl_lock exclusively, and if the pf_state_item kmalloc(M_NOWAIT) fails the error path calls pf_state_key_detach, which re-acquires the same lock exclusively; the lock is initialized without LK_CANRECURSE so lockmgr panics with locking against myself - a memory shortage on the packet path becomes a remote-triggered panic. Forcing a mid-function M_NOWAIT failure under memory pressure at the exact allocation is not practical on this guest. Fix releases the global lock before the detach and re-acquires it; compile-validated.

## Kernel references
- sys/net/pf/pf.c:915-918
- sys/net/pf/pf.c:955-985

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

## Fix

drop and re-acquire the global lock around the error-path detach

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

## Reproduction

build: n/a (cannot force the M_NOWAIT failure)

run: n/a

expected: n/a

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

(none)

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