Skip to content

Commit 40b9d1a

Browse files
Mahesh Bandewardavem330
authored andcommitted
ipvlan: hold lower dev to avoid possible use-after-free
Recently syzkaller discovered the issue of disappearing lower device (NETDEV_UNREGISTER) while the virtual device (like macvlan) is still having it as a lower device. So it's just a matter of time similar discovery will be made for IPvlan device setup. So fixing it preemptively. Also while at it, add a refcount tracker. Fixes: 2ad7bf3 ("ipvlan: Initial check-in of the IPVLAN driver.") Signed-off-by: Mahesh Bandewar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8207f25 commit 40b9d1a

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

drivers/net/ipvlan/ipvlan.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct ipvl_port {
9898
struct sk_buff_head backlog;
9999
int count;
100100
struct ida ida;
101+
netdevice_tracker dev_tracker;
101102
};
102103

103104
struct ipvl_skb_cb {

drivers/net/ipvlan/ipvlan_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static int ipvlan_port_create(struct net_device *dev)
8383
if (err)
8484
goto err;
8585

86+
netdev_hold(dev, &port->dev_tracker, GFP_KERNEL);
8687
return 0;
8788

8889
err:
@@ -95,6 +96,7 @@ static void ipvlan_port_destroy(struct net_device *dev)
9596
struct ipvl_port *port = ipvlan_port_get_rtnl(dev);
9697
struct sk_buff *skb;
9798

99+
netdev_put(dev, &port->dev_tracker);
98100
if (port->mode == IPVLAN_MODE_L3S)
99101
ipvlan_l3s_unregister(port);
100102
netdev_rx_handler_unregister(dev);

0 commit comments

Comments
 (0)