]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
tuntap: Defer clearing if_softc until after if_detach
authorkevans <kevans@FreeBSD.org>
Tue, 14 May 2019 20:32:29 +0000 (20:32 +0000)
committerkevans <kevans@FreeBSD.org>
Tue, 14 May 2019 20:32:29 +0000 (20:32 +0000)
commitcd7faca79aa0c08b2ca4a4d25c1a6f706fe75642
tree7aa175772b329856052d77ae0984be1a1ce86a55
parent54299441cba3880ab402b9c165538d840052fbf8
tuntap: Defer clearing if_softc until after if_detach

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.

Reported by: markj
MFC after: 3 days
sys/net/if_tuntap.c