HomeFreeBSD

if_tuntap: defer transient destroy_dev() to a taskqueue

Description

if_tuntap: defer transient destroy_dev() to a taskqueue

We're in the dtor, so we can't destroy it now without deadlocking after
recent changes to make destroy_dev() provide a barrier. However, we
know there isn't any other dtor to run, so we can go ahead and clean up
our state and just prevent a use-after-free if someone races to open
the device while we're trying to destroy it. tunopen() now uses the
net epoch to protect against softc release by a concurrent
tun_destroy().

While we're here, allow a destroy operation to proceed if we caught a
signal in cv_wait_sig() but tun_busy dropped to 0 while we were waiting
to acquire the lock.

This was more of an inherent design flaw, rather than a bug in the
below-refed commit.

PR: 290575
Fixes: 4dbe6628179d ("devfs: make destroy_dev() a release [...]")
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D53438

Details

Provenance
kevansAuthored on Wed, Nov 5, 12:28 AM
Reviewer
kib
Differential Revision
D53438: if_tuntap: defer transient destroy_dev() to a taskqueue
Parents
rG7d495be8d4bd: exterr: print exterr for struct buf and bio in ddb show commands
Branches
Unknown
Tags
Unknown