[Bug 242841] Unkillable process when attempting to destroy an open tun device

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Dec 23 20:08:45 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242841

            Bug ID: 242841
           Summary: Unkillable process when attempting to destroy an open
                    tun device
           Product: Base System
           Version: 12.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs at FreeBSD.org
          Reporter: cperciva at FreeBSD.org

This is admittedly partly a case of "don't do that" (I tripped over it due to a
bug in code I was writing), but it seems like the kernel should handle it a bit
more gracefully.

If you:

1. Create a tun device (via SIOCIFCREATE),
2. Open the tun device (via open("/dev/tun#")), and then
3. Attempt to destroy the tun device (via SIOCIFDESTROY),

the SIOCIFDESTROY ioctl will block on tun_condvar until the last file
descriptor holding the device open has been closed.  Generally sensible...
except that the file descriptor in question is owned by the process which
called the ioctl, and it's stuck inside the kernel now and will never be able
to close the device.  This results in a process which cannot be killed.

A better solution might be to detect when the process calling SIOCIFDESTROY is
the same as the process which owns the tunnel device, and return an error
(maybe EBUSY) rather than blocking indefinitely.

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


More information about the freebsd-bugs mailing list