]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r347578: tun/tap: Defer clearing if_softc until after if_detach
authorKyle Evans <kevans@FreeBSD.org>
Wed, 22 May 2019 22:34:35 +0000 (22:34 +0000)
committerKyle Evans <kevans@FreeBSD.org>
Wed, 22 May 2019 22:34:35 +0000 (22:34 +0000)
commitd1f3029399467f6b34e5b219e00c8b350c2b70d1
tree83dcf8ef1d3988f19e48a25998e7340284ff9e04
parent0fc88f2792876e4495d906a10d6a3e4b84986608
MFC r347578: tun/tap: Defer clearing if_softc until after if_detach

(Commit massaged to match stable structure; tun and tap have been merged in
head)

r346670 added an sx to close a race between the ifioctl handler and
interface destruction. Unfortunately, it clears if_softc immediately after
the interface is closed, but before if_detach has been invoked.

Any time before detachment, an interface that's part of a bridge may still
receive traffic that's pushed through tunstart/tunstart_l2 and promptly
lead to a panic because if_softc is now NULL.

Fix it by deferring the clearing of if_softc until after the interface has
detached and thus been removed from the bridge. if_softc still gets cleared
in case another thread has already entered the ioctl handler before it's
replaced with ifdead_ioctl.
sys/net/if_tap.c
sys/net/if_tun.c