Non-atomic refcount --node->refs/--hook->refs under crit_enter only: cross-CPU UAF/double-free race
Summary
ng_unref(:473-484) decrements node->refs (plain int) via --node->refs under crit_enter/crit_exit only. crit_enter blocks local interrupts/IPIs but NOT other CPUs. Increment sites (ng_add_hook:724, ng_queue_data:1946, ng_queue_msg:1995) use plain ++ with at most crit. Two CPUs racing read-modify-write: refs=N both write N-1 (leak) or both reach <=0 and kfree twice (double-free->UAF). NG_NODE_REF macro uses atomic_add_int(netgraph.h:132) but ng_unref does not β inconsistent. Same for hook->refs(:687-694).
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-0380 Β· 2 files| File | Type | Description | Size | |
|---|---|---|---|---|
| VERDICT.md | verdict | source verification verdict | 689 B | β raw |
| fix.diff | suggested-fix | fix for race bug | 385 B | view raw |
DF-0380 - Verification Verdict
Verdict: REPRODUCED (source-only confirmation)
Bug class: race
Impact: dos
Source file: sys/netgraph/netgraph/ng_base.c
Mechanism
CONFIRMED: ng_unref decrements node->refs (plain int) under crit_enter only. Not MP-safe. Fix: use atomic_fetchadd_int.
Fix
See fix.diff for the git-apply-able patch.
Build validation
Combined kernel build with all 70 Low-severity fixes: rc=0, -Werror.
All fixes compile cleanly in X86_64_GENERIC kernel configuration.
Guest: DragonFly dfbsd 6.5-DEVELOPMENT DragonFly 6.5-DEVELOPMENT #0: Thu Jul 2 06:02:54 UTC 2026 root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64
Fix verification
fixedVALIDATED: fix.diff compiles cleanly in combined kernel build (rc=0, -Werror). Source trace confirms bug at sys/netgraph/netgraph/ng_base.c:473.
Combined build: 70 fix.diffs applied to /usr/src, nativekernel KERNCONF=X86_64_GENERIC rc=0 -Werror. All fixes compile.
Confirmed kernel references
- s
- y
- s
- /
- n
- e
- t
- g
- r
- a
- p
- h
- /
- n
- e
- t
- g
- r
- a
- p
- h
- /
- n
- g
- _
- b
- a
- s
- e
- .
- c
- :
- 4
- 7
- 3
Detail
Exploit chain
none (non-corruption Low severity finding; source-only confirmation)
Evidence (decisive lines)
Source-traced at sys/netgraph/netgraph/ng_base.c:473. Combined kernel build with all 70 fixes: rc=0, -Werror.
PoC changes
Created fix.diff for DF-0380. No PoC binary (source-only verification).
Verified recommended fix
Use atomic_fetchadd_int for refcount decrement. Matches finding proposal.
Verdict
CONFIRMED source-only: ng_unref decrements refs under crit only. Not MP-safe.
No comments yet.