]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r347578: tun/tap: Defer clearing if_softc until after if_detach
authorkevans <kevans@FreeBSD.org>
Wed, 22 May 2019 22:56:05 +0000 (22:56 +0000)
committerkevans <kevans@FreeBSD.org>
Wed, 22 May 2019 22:56:05 +0000 (22:56 +0000)
commit263cd01bcc809890088962bf3689008716bf28ff
tree5ba51eb50efb47a4871d5367088af418c34c34b4
parentec43aacbf5a4d87321ac37fa0e98f6b33a46373b
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.

Approved by: re (kib)
sys/net/if_tap.c
sys/net/if_tun.c