HomeFreeBSD

netgraph: Fix ng_ether's shutdown handing

Description

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

(cherry picked from commit cd698c51790e956fed0975f451d3dfc361dc7c24)

Details

Provenance
markjAuthored on Dec 23 2020, 5:11 AM
Parents
rGf0350417eb3c: acpi: Ensure that adjacent memory affinity table entries are coalesced
Branches
Unknown
Tags
Unknown