Message ID | 20250103140813.79819-1-kuniyu@amazon.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [v2,net] ipvlan: Fix use-after-free in ipvlan_get_iflink(). | expand |
On Fri, 3 Jan 2025 23:08:13 +0900 Kuniyuki Iwashima wrote:
> + if (dev->reg_state <= NETREG_UNREGISTERED)
s/UN//
From: Jakub Kicinski <kuba@kernel.org> Date: Fri, 3 Jan 2025 08:06:45 -0800 > On Fri, 3 Jan 2025 23:08:13 +0900 Kuniyuki Iwashima wrote: > > + if (dev->reg_state <= NETREG_UNREGISTERED) > > s/UN// Oops, will fix it, thanks!
diff --git a/net/core/link_watch.c b/net/core/link_watch.c index 1b4d39e38084..6881f736ad14 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_UNREGISTERED) + iflink = dev_get_iflink(dev); + else + iflink = dev->ifindex; + + if (iflink == dev->ifindex) return IF_OPER_DOWN; ASSERT_RTNL();