[Bug 295614] tun_destroy() holds ifnet_detach_sxlock while sleeping on tun_cv

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 26 May 2026 17:29:55 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295614

            Bug ID: 295614
           Summary: tun_destroy() holds ifnet_detach_sxlock while sleeping
                    on tun_cv
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: olivier@freebsd.org

On FreeBSD 16-CURRENT (reproduced against main-n286096-490c53e9353f), `ifconfig
tunN destroy` against a tun(4) device that has an open consumer wedges the
kernel's ifnet-clone subsystem indefinitely.

Reproducer (three commands, no special hardware or modules):

ifconfig tun create                                  # -> tun1
sleep 99999 < /dev/tun1 &
ifconfig tun1 destroy

The third command never returns. From that point on, every subsequent `ifconfig
<anything> destroy`, `jail -R` that touches a cloned interface, and `jls` (via
the allprison cascade described below) blocks in uninterruptible-style sleep.
SIGKILL on the wedged ifconfig does not break it. Only a reboot recovers.

-- 
You are receiving this mail because:
You are the assignee for the bug.