aboutsummaryrefslogtreecommitdiff
path: root/sys/netgraph/ng_base.c
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2020-12-23 05:11:16 +0000
committerMark Johnston <markj@FreeBSD.org>2020-12-23 05:12:16 +0000
commitcd698c51790e956fed0975f451d3dfc361dc7c24 (patch)
treef4b132bafecb4c3d775b43adda68f2fab7b04707 /sys/netgraph/ng_base.c
parent1cc908de3ab2e11fca648fc874df2f9d255fc087 (diff)
downloadsrc-cd698c51790e956fed0975f451d3dfc361dc7c24.tar.gz
src-cd698c51790e956fed0975f451d3dfc361dc7c24.zip
netgraph: Fix ng_ether's shutdown handing
When tearing down a VNET, netgraph sends shutdown messages to all of the nodes before detaching interfaces (SI_SUB_NETGRAPH comes before SI_SUB_INIT_IF in teardown order). ng_ether nodes handle this by destroying themselves without detaching from the parent ifnet. Then, when ifnets go away they detach their ng_ether nodes again, triggering a use-after-free. Handle this by modifying ng_ether_shutdown() to detach from the ifnet. If the shutdown was triggered by an ifnet being destroyed, we will clear priv->ifp in the ng_ether detach callback, so priv->ifp may be NULL. Also get rid of the printf in vnet_netgraph_uninit(). It can be triggered trivially by ng_ether since ng_ether_shutdown() persists the node unless NG_REALLY_DIE is set. PR: 233622 Reviewed by: afedorov, kp, Lutz Donnerhacke MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27662
Diffstat (limited to 'sys/netgraph/ng_base.c')
-rw-r--r--sys/netgraph/ng_base.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c
index c5b38dc1fdd6..dadf86eb8dde 100644
--- a/sys/netgraph/ng_base.c
+++ b/sys/netgraph/ng_base.c
@@ -3166,12 +3166,10 @@ vnet_netgraph_uninit(const void *unused __unused)
/* Attempt to kill it only if it is a regular node */
if (node != NULL) {
if (node == last_killed) {
- /* This should never happen */
- printf("ng node %s needs NGF_REALLY_DIE\n",
- node->nd_name);
if (node->nd_flags & NGF_REALLY_DIE)
panic("ng node %s won't die",
node->nd_name);
+ /* The node persisted itself. Try again. */
node->nd_flags |= NGF_REALLY_DIE;
}
ng_rmnode(node, NULL, NULL, 0);