ipvlan: hold lower dev to avoid possible use-after-free
Subsystems (2)
PATCH 1/1 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.
--- drivers/net/ipvlan/ipvlan.h | 1 + drivers/net/ipvlan/ipvlan_main.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/net/ipvlan/ipvlan.h +1 -0
@@ -98,6 +98,7 @@ struct ipvl_port {struct sk_buff_head backlog;int count;struct ida ida; +netdevice_tracker dev_tracker; };struct ipvl_skb_cb {
drivers/net/ipvlan/ipvlan_main.c +2 -0
@@ -83,6 +83,7 @@ static int ipvlan_port_create(struct net_device *dev)if (err) goto err; +netdev_hold (dev, &port->dev_tracker,GFP_KERNEL );return 0 ; err:
@@ -95,6 +96,7 @@ static void ipvlan_port_destroy(struct net_device *dev)struct ipvl_port *port =ipvlan_port_get_rtnl (dev);struct sk_buff *skb; +netdev_put (dev, &port->dev_tracker);if (port->mode ==IPVLAN_MODE_L3S )ipvlan_l3s_unregister (port);netdev_rx_handler_unregister (dev);
Signature · 1 line
2.38.1.431.g37b22c650d-goog
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 8 lines · On Tue, 15 Nov 2022 17:19:14 -0800 you wrote:
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.[...]
Here is the summary with links:
- [net] ipvlan: hold lower dev to avoid possible use-after-free
https://git.kernel.org/netdev/net/c/40b9d1ab63f5
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html