β¬’ DragonFlyBSD Kernel Audit
← triage Β· dashboard
DF-3411

FIOSETOWN/TIOCSPGRP racing pgsigio: tun's async-SIGIO paths dereference a struct sigio that funsetown() frees outside sigio_token (generic UAF primitive, tun manifestation)

Summary

tunioctl's FIOSETOWN/TIOCSPGRP call fsetown -> funsetown, which clears *sigiop under sigio_token but removes/kfrees the sigio AFTER dropping the token. The TX-side pgsigio callers (tunifoutput_serialized, tunifstart) read sc->tun_sigio without that token and pgsigio() itself dereferences sigio->sio_pgid/sio_proc/sio_pgrp with no locking - a freed sigio is dereferenced and pgref/pgrel'd (UAF). FreeBSD holds SIGIO_LOCK() inside pgsigio; DragonFly does not. Same pattern in tap and other drivers using this idiom. Root-only both sides; narrow window. Fix: take sigio_token in pgsigio (cross-file kern_sig.c) or refcounted lookup. [VERIFIED pass2: about 55s hammer no hit - handful-of-instructions window line-confirmed funsetown drops token before removal while pgsigio takes none; token fix compile-validated]

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-3411 Β· 5 files
FileTypeDescriptionSize
README.md β€” 950 B ↓ raw
VERDICT.md β€” 2.1 KB ↓ raw
manifest.json β€” 754 B view raw
race_sigio.c β€” 2.3 KB view raw
verdict.json β€” 1.6 KB view raw

DF-3411 -- verification pack

Method: Code-line analysis + attempted live reproduction Status: NOT REPRODUCED | impact: none | confidence: likely

What this is

funsetown (kern_descrip.c:1239-1273) drops sigio_token BEFORE the list removal/crfree/kfree while pgsigio (kern_sig.c:2639) derefs the sigio with no token: tunifstart's pgsigio(sc->tun_sigio) racing a concurrent FIOSETOWN is a genuine use-after-free window. Stress attempted live (FIOSETOWN hammer + continuous tun0 traffic driving tunifstart): ~55s combined, no crash; window is a handful of instructions. Mechanism line-confirmed.

Build

cc -O -o <prog> <prog>.c   (on the guest)

Run

20 (root)

(success criterion: see VERDICT.md)

Evidence

VERDICT.md run log: FIOSETOWN storm + ping/UDP traffic through tun0, rc=124 (alive, no crash)

Kernel references: sys/net/tun/if_tun.c:533-536, sys/kern/kern_descrip.c:1239-1273, sys/kern/kern_sig.c:2639-2663

VERDICT.md
↓ download raw

DF-3411 -- VERDICT

NOT REPRODUCED (impact=none, confidence=likely) 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

funsetown (kern_descrip.c:1239-1273) drops sigio_token BEFORE the list removal/crfree/kfree while pgsigio (kern_sig.c:2639) derefs the sigio with no token: tunifstart's pgsigio(sc->tun_sigio) racing a concurrent FIOSETOWN is a genuine use-after-free window. Stress attempted live (FIOSETOWN hammer + continuous tun0 traffic driving tunifstart): ~55s combined, no crash; window is a handful of instructions. Mechanism line-confirmed.

How it was verified

  • Method: Code-line analysis + attempted live reproduction
  • Kernel references: sys/net/tun/if_tun.c:533-536, sys/kern/kern_descrip.c:1239-1273, sys/kern/kern_sig.c:2639-2663
  • Evidence: VERDICT.md run log: FIOSETOWN storm + ping/UDP traffic through tun0, rc=124 (alive, no crash)
  • 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: not_testable -- Fix: hold sigio_token across the pgsigio body (or make tun read sc->tun_sigio under the token); needs fault injection to A/B.

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.

(No fix.diff for this item: documented recommendation only - see Fix above.)

Fix verification

not_testable

Fix: hold sigio_token across the pgsigio body (or make tun read sc->tun_sigio under the token); needs fault injection to A/B.

per-fix-DF-3411

Confirmed kernel references

Detail

Evidence (decisive lines)

VERDICT.md run log: FIOSETOWN storm + ping/UDP traffic through tun0, rc=124 (alive, no crash)

Verdict

funsetown (kern_descrip.c:1239-1273) drops sigio_token BEFORE the list removal/crfree/kfree while pgsigio (kern_sig.c:2639) derefs the sigio with no token: tunifstarts pgsigio(sc->tun_sigio) racing a concurrent FIOSETOWN is a genuine use-after-free window. Stress attempted live (FIOSETOWN hammer + continuous tun0 traffic driving tunifstart): ~55s combined, no crash; window is a handful of instructions. Mechanism line-confirmed.