Re: [syzbot] [net?] general protection fault in rtnl_create_link

Kuniyuki Iwashima
2025-04-14T18:03:12Z

From: Jakub Kicinski <kuba@kernel.org>
Date: Mon, 14 Apr 2025 10:37:27 -0700
> On Sun, 13 Apr 2025 19:30:46 -0700 Kuniyuki Iwashima wrote:
> > diff --git a/include/net/netdev_lock.h b/include/net/netdev_lock.h
> > index 5706835a660c..270e157a4a79 100644
> > --- a/include/net/netdev_lock.h
> > +++ b/include/net/netdev_lock.h
> > @@ -30,7 +30,8 @@ static inline bool netdev_need_ops_lock(const struct net_device *dev)
> > bool ret = dev->request_ops_lock || !!dev->queue_mgmt_ops;
> >
> > #if IS_ENABLED(CONFIG_NET_SHAPER)
> > - ret |= !!dev->netdev_ops->net_shaper_ops;
> > + if (dev->netdev_ops)
> > + ret |= !!dev->netdev_ops->net_shaper_ops;
> > #endif
>
> This is a bit surprising, we pretty much never validate if dev has ops.
>
> I think we're guaranteed that IFF_UP will not be set if we just
> allocated the device, so we can remove the locks in rtnl_create_link()
> and to double confirm add a netdev_ops_assert_locked_or_invisible()
> in netif_state_change() ?

Removing the lock from NEWLINK makes sense, but my concern
was NETDEV_CHANGE, which will requires more caution ?

commit 04efcee6ef8d0f01eef495db047e7216d6e6e38f
Author: Stanislav Fomichev <sdf@fomichev.me>
Date: Fri Apr 4 09:11:22 2025 -0700

net: hold instance lock during NETDEV_CHANGE