netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] ipvlan: hold lower dev to avoid possible use-after-free
@ 2022-11-16  1:19 Mahesh Bandewar
  2022-11-18 10:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Mahesh Bandewar @ 2022-11-16  1:19 UTC (permalink / raw)
  To: Netdev
  Cc: Eric Dumazet, David Miller, Jakub Kicinski, Mahesh Bandewar,
	Mahesh Bandewar

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: 2ad7bf363841 ("ipvlan: Initial check-in of the IPVLAN driver.")

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
---
 drivers/net/ipvlan/ipvlan.h      | 1 +
 drivers/net/ipvlan/ipvlan_main.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/drivers/net/ipvlan/ipvlan.h b/drivers/net/ipvlan/ipvlan.h
index de94921cbef9..025e0c19ec25 100644
--- a/drivers/net/ipvlan/ipvlan.h
+++ b/drivers/net/ipvlan/ipvlan.h
@@ -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 {
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index b6bfa9fdca62..b15dd9a3ad54 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -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);
-- 
2.38.1.431.g37b22c650d-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] ipvlan: hold lower dev to avoid possible use-after-free
  2022-11-16  1:19 [PATCH net] ipvlan: hold lower dev to avoid possible use-after-free Mahesh Bandewar
@ 2022-11-18 10:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-11-18 10:50 UTC (permalink / raw)
  To: Mahesh Bandewar; +Cc: netdev, edumazet, davem, kuba, mahesh

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-18 10:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16  1:19 [PATCH net] ipvlan: hold lower dev to avoid possible use-after-free Mahesh Bandewar
2022-11-18 10:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).