if_clone_destroy() lookup/act TOCTOU: drops the ifnet lock between ifunit() lookup and teardown β concurrent destroyers double-free the clone unit and UAF the ifnet (framework component of the reproduced DF-3407 panic)
Summary
if_clone_destroy() looks the ifnet up under ifnet_lock, RELEASES the lock, then re-acquires it and runs if_clone_free_unit + ifc_destroy on the stale ifp. Two concurrent destroyers of the same unit (e.g. tunclose's self-destroy racing a user SIOCIFDESTROY, or two racing ifconfig destroys of ANY clonable interface) both pass the lookup and then double-run teardown: on INVARIANTS kernels the KKASSERT 'if_clone_free_unit: bit is already cleared' fires (observed twice on the guest); on production kernels it is a double bit-clear plus ifc_destroy on an already-freed ifnet - use-after-free. Proven empirically as part of DF-3407: tun-side serialization alone still panicked with this exact signature; adding the lock-across-lookup fix made 2x120s of racing clean. Affects every cloner (tun, tap, vlan, gif, ...), root-only. Fix: hold ifnet_lock across lookup..teardown (validated in the DF-3407 pack's fix.diff). [VERIFIED pass2: reproduced live - dedicated destroyer-vs-destroyer race panicked the INVARIANTS guest twice via if_clone_free_unit bit-already-cleared; lock-across fix cross-validated by the DF-3407 pack]
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-3414 Β· 8 files| File | Type | Description | Size | |
|---|---|---|---|---|
| README.md | β | 981 B | β raw | |
| VERDICT.md | β | 2.3 KB | β raw | |
| fix.diff | β | 1.0 KB | view raw | |
| manifest.json | β | 747 B | view raw | |
| panic.2.txt | β | 503 B | view raw | |
| panic.txt | β | 503 B | view raw | |
| race_clone.c | β | 2.8 KB | view raw | |
| verdict.json | β | 1.8 KB | view raw |
DF-3414 -- verification pack
Method: Live PoC on the QEMU guest (stock INVARIANTS kernel) Status: REPRODUCED | impact: panic | confidence: certain
What this is
if_clone_destroy drops the ifnet lock between ifunit() lookup and teardown: two concurrent SIOCIFDESTROY destroyers both pass the lookup and double-run if_clone_free_unit + ifc->ifc_destroy. Reproduced TWICE on this guest with a dedicated destroyer-vs-destroyor race (no tun cdev involvement): panic 'if_clone_free_unit: bit is already cleared', trace if_clone_destroy <- ifioctl <- syscall2. On non-INVARIANTS kernels the same interleaving is a double bit-clear plus ifc->ifc_destroy on a freed ifnet (UAF).
Build
cc -O -o <prog> <prog>.c (on the guest)
Run
60 (root)
(success criterion: see VERDICT.md)
Evidence
panic.txt + panic.2.txt (two independent panics, full traces); race_clone.c
Kernel references: sys/net/if_clone.c:104-135, sys/net/if_clone.c:if_clone_free_unit
DF-3414 -- VERDICT
REPRODUCED (impact=panic, confidence=certain) 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
Summary
if_clone_destroy drops the ifnet lock between ifunit() lookup and teardown: two concurrent SIOCIFDESTROY destroyers both pass the lookup and double-run if_clone_free_unit + ifc->ifc_destroy. Reproduced TWICE on this guest with a dedicated destroyer-vs-destroyor race (no tun cdev involvement): panic 'if_clone_free_unit: bit is already cleared', trace if_clone_destroy <- ifioctl <- syscall2. On non-INVARIANTS kernels the same interleaving is a double bit-clear plus ifc->ifc_destroy on a freed ifnet (UAF).
How it was verified
- Method: Live PoC on the QEMU guest (stock INVARIANTS kernel)
- Kernel references: sys/net/if_clone.c:104-135, sys/net/if_clone.c:if_clone_free_unit
- Evidence: panic.txt + panic.2.txt (two independent panics, full traces); race_clone.c
- Reachability: local-unpriv where noted in the summary; root-config for tun/lagg/carp/ipfw3/gre items; remote-facing for the packet parsers (wlan harnesses model the RX/TX path verbatim because the guest has no 802.11 hardware; precedent DF-0393/DF-0594/DF-0621/DF-0350).
- Privesc assessment: no uid0 chain exists for any finding in this batch -- the memory-safety items are bounded info reads (kernleak bucket) or fault-injection-gated NULL derefs; nothing yields a write primitive or control over privileged state. The one panic-class live item (DF-3414) is root-only (SIOCIFDESTROY).
Fix
fix_status: fixed -- The lock-across-lookup fix was already A/B-validated on this same guest by the DF-3407 pack (patched kernel #3: 2x120s of the same racing clean, panic gone; see findings/poc/DF-3407). fix.diff here carries the identical change. fix.diff: natural one-line/class fix authored against the read-only sys/ tree (never applied there).
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.
Fix verification
fixedThe lock-across-lookup fix was A/B-validated on this same guest by the DF-3407 pack (patched kernel #3 there: 2x120s of the identical destroy racing ran clean, panic gone). fix.diff carries the identical change; baseline here reproduced the panic twice independently (panic.txt, panic.2.txt).
Confirmed kernel references
- sys/net/if_clone.c:104-135
- sys/net/if_clone.c:if_clone_free_unit
Detail
Evidence (decisive lines)
panic.txt + panic.2.txt (two independent panics, full traces); race_clone.c
Verified recommended fix
fix.diff
Verdict
if_clone_destroy drops the ifnet lock between ifunit() lookup and teardown: two concurrent SIOCIFDESTROY destroyers both pass the lookup and double-run if_clone_free_unit + ifc->ifc_destroy. Reproduced TWICE on this guest with a dedicated destroyer-vs-destroyor race (no tun cdev involvement): panic if_clone_free_unit: bit is already cleared, trace if_clone_destroy <- ifioctl <- syscall2. On non-INVARIANTS kernels the same interleaving is a double bit-clear plus ifc->ifc_destroy on a freed ifnet (UAF).
No comments yet.