[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250414111536.6d6493f1@kernel.org>
Date: Mon, 14 Apr 2025 11:15:36 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Kuniyuki Iwashima <kuniyu@...zon.com>
Cc: <cratiu@...dia.com>, <davem@...emloft.net>, <edumazet@...gle.com>,
<horms@...nel.org>, <linux-kernel@...r.kernel.org>,
<netdev@...r.kernel.org>, <pabeni@...hat.com>, <sdf@...ichev.me>,
<syzbot+de1c7d68a10e3f123bdd@...kaller.appspotmail.com>,
<syzkaller-bugs@...glegroups.com>
Subject: Re: [syzbot] [net?] general protection fault in rtnl_create_link
On Mon, 14 Apr 2025 11:01:59 -0700 Kuniyuki Iwashima wrote:
> From: Jakub Kicinski <kuba@...nel.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@...ichev.me>
> Date: Fri Apr 4 09:11:22 2025 -0700
>
> net: hold instance lock during NETDEV_CHANGE
How could we fire a notifier for a device that hasn't been initialized,
let alone registered?
I'm hoping that the _or_invisible assert in my suggestion will flag to
future developers trying to change netif_state_change() that the device
here may not be fully constructed.
Powered by blists - more mailing lists