]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit - sys/net/if.c
if: Fix panic when destroying vnet and epair simultaneously
authorkp <kp@FreeBSD.org>
Tue, 1 Dec 2020 16:23:59 +0000 (16:23 +0000)
committerkp <kp@FreeBSD.org>
Tue, 1 Dec 2020 16:23:59 +0000 (16:23 +0000)
commit12799dc65c5d50268a6f538b8c27933ab70b83f5
tree046cba8db59634a150879f1f608652f33f7f3e39
parentb3e6bab67719adf2ae352d877b765d3565864252
if: Fix panic when destroying vnet and epair simultaneously

When destroying a vnet and an epair (with one end in the vnet) we often
panicked. This was the result of the destruction of the epair, which destroys
both ends simultaneously, happening while vnet_if_return() was moving the
struct ifnet to its home vnet. This can result in a freed ifnet being re-added
to the home vnet V_ifnet list. That in turn panics the next time the ifnet is
used.

Prevent this race by ensuring that vnet_if_return() cannot run at the same time
as if_detach() or epair_clone_destroy().

PR: 238870, 234985, 244703, 250870
MFC after: 2 weeks
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D27378
sys/net/if.c