Message ID | 20250106071911.64355-1-kuniyu@amazon.com (mailing list archive) |
---|---|
State | Accepted |
Commit | cb358ff94154774d031159b018adf45e17673941 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [v3,net] ipvlan: Fix use-after-free in ipvlan_get_iflink(). | expand |
Hello: This patch was applied to netdev/net.git (main) by Jakub Kicinski <kuba@kernel.org>: On Mon, 6 Jan 2025 16:19:11 +0900 you wrote: > syzbot presented an use-after-free report [0] regarding ipvlan and > linkwatch. > > ipvlan does not hold a refcnt of the lower device unlike vlan and > macvlan. > > If the linkwatch work is triggered for the ipvlan dev, the lower dev > might have already been freed, resulting in UAF of ipvlan->phy_dev in > ipvlan_get_iflink(). > > [...] Here is the summary with links: - [v3,net] ipvlan: Fix use-after-free in ipvlan_get_iflink(). https://git.kernel.org/netdev/net/c/cb358ff94154 You are awesome, thank you!
diff --git a/net/core/link_watch.c b/net/core/link_watch.c index 1b4d39e38084..cb04ef2b9807 100644 --- a/net/core/link_watch.c +++ b/net/core/link_watch.c @@ -42,14 +42,18 @@ static unsigned int default_operstate(const struct net_device *dev) * first check whether lower is indeed the source of its down state. */ if (!netif_carrier_ok(dev)) { - int iflink = dev_get_iflink(dev); struct net_device *peer; + int iflink; /* If called from netdev_run_todo()/linkwatch_sync_dev(), * dev_net(dev) can be already freed, and RTNL is not held. */ - if (dev->reg_state == NETREG_UNREGISTERED || - iflink == dev->ifindex) + if (dev->reg_state <= NETREG_REGISTERED) + iflink = dev_get_iflink(dev); + else + iflink = dev->ifindex; + + if (iflink == dev->ifindex) return IF_OPER_DOWN; ASSERT_RTNL();