Skip to content

Commit

Permalink
veth: fix NULL dereference in veth_dellink()
Browse files Browse the repository at this point in the history
commit d0e2c55 (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: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Feb 11, 2013
1 parent 715448f commit f45a5c2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/net/veth.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,13 @@ static void veth_dellink(struct net_device *dev, struct list_head *head)
* not being freed before one RCU grace period.
*/
RCU_INIT_POINTER(priv->peer, NULL);

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

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

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

static const struct nla_policy veth_policy[VETH_INFO_MAX + 1] = {
Expand Down

0 comments on commit f45a5c2

Please sign in to comment.