Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f45a5c26 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

veth: fix NULL dereference in veth_dellink()



commit d0e2c55e (veth: avoid a NULL deref in veth_stats_one)
added another NULL deref in veth_dellink().

# ip link add name veth1 type veth peer name veth0
# rmmod veth

We crash because veth_dellink() is called twice, so we must
take care of NULL peer.

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 715448ff
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -426,13 +426,14 @@ static void veth_dellink(struct net_device *dev, struct list_head *head)
	 * not being freed before one RCU grace period.
	 * not being freed before one RCU grace period.
	 */
	 */
	RCU_INIT_POINTER(priv->peer, NULL);
	RCU_INIT_POINTER(priv->peer, NULL);
	unregister_netdevice_queue(dev, head);


	if (peer) {
		priv = netdev_priv(peer);
		priv = netdev_priv(peer);
		RCU_INIT_POINTER(priv->peer, NULL);
		RCU_INIT_POINTER(priv->peer, NULL);

	unregister_netdevice_queue(dev, head);
		unregister_netdevice_queue(peer, head);
		unregister_netdevice_queue(peer, head);
	}
	}
}


static const struct nla_policy veth_policy[VETH_INFO_MAX + 1] = {
static const struct nla_policy veth_policy[VETH_INFO_MAX + 1] = {
	[VETH_INFO_PEER]	= { .len = sizeof(struct ifinfomsg) },
	[VETH_INFO_PEER]	= { .len = sizeof(struct ifinfomsg) },