public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Fomichev <stfomichev@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: sdf@fomichev.me, Kuniyuki Iwashima <kuniyu@amazon.com>,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	horms@kernel.org, hramamurthy@google.com, jdamato@fastly.com,
	netdev@vger.kernel.org, pabeni@redhat.com
Subject: Re: [PATCH net-next v2 6/8] netdev: depend on netdev->lock for xdp features
Date: Fri, 11 Apr 2025 10:41:58 -0700	[thread overview]
Message-ID: <Z_lUZgRc9JYhjnIG@mini-arch> (raw)
In-Reply-To: <20250410192326.0a5dbb10@kernel.org>

On 04/10, Jakub Kicinski wrote:
> On Thu, 10 Apr 2025 19:10:28 -0700 Jakub Kicinski wrote:
> > On Thu, 10 Apr 2025 10:10:01 -0700 Kuniyuki Iwashima wrote:
> > > syzkaller reported splats in register_netdevice() and
> > > unregister_netdevice_many_notify().
> > > 
> > > In register_netdevice(), some devices cannot use
> > > netdev_assert_locked().
> > > 
> > > In unregister_netdevice_many_notify(), maybe we need to
> > > hold ops lock in UNREGISTER as you initially suggested.
> > > Now do_setlink() deadlock does not happen.  
> > 
> > Ah...  Thank you.
> > 
> > Do you have a reference to use as Reported-by, or its from a
> > non-public instance ?
> > 
> > I'll test this shortly:
> > 
> > diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
> > index b64c614a00c4..891e2f60922f 100644
> > --- a/net/core/netdev-genl.c
> > +++ b/net/core/netdev-genl.c
> > @@ -38,7 +38,8 @@ netdev_nl_dev_fill(struct net_device *netdev, struct sk_buff *rsp,
> >         u64 xdp_rx_meta = 0;
> >         void *hdr;
> >  
> > -       netdev_assert_locked(netdev); /* note: rtnl_lock may not be held! */
> > +       /* note: rtnl_lock may or may not be held! */
> > +       netdev_assert_locked_or_invisible(netdev);
> >  
> >         hdr = genlmsg_iput(rsp, info);
> >         if (!hdr)
> > @@ -966,7 +967,9 @@ static int netdev_genl_netdevice_event(struct notifier_block *nb,
> >                 netdev_genl_dev_notify(netdev, NETDEV_CMD_DEV_ADD_NTF);
> >                 break;
> >         case NETDEV_UNREGISTER:
> > +               netdev_lock(netdev);
> >                 netdev_genl_dev_notify(netdev, NETDEV_CMD_DEV_DEL_NTF);
> > +               netdev_unlock(netdev);
> >                 break;
> >         case NETDEV_XDP_FEAT_CHANGE:
> >                 netdev_genl_dev_notify(netdev, NETDEV_CMD_DEV_CHANGE_NTF);
> 
> Ugh, REGISTER is ops locked we'd need conditional locking here.
> 
> Stanislav, I can make the REGISTERED notifier fully locked, right?
> I suspect any new object we add that's protected by the instance
> lock will want to lock the dev.

Are you suggesting to do s/netdev_lock_ops/netdev_lock/ around
call_netdevice_notifiers in register_netdevice? We can try, the biggest
concern, as usual, are the stacking devices (with an extra lock), but
casually grepping for NETDEV_REGISTER doesn't bring up anything
suspicious.

But if you're gonna do conditional locking for NETDEV_UNREGISTER, any
reason not to play it safe and add conditional locking to NETDEV_REGISTER
in netdev_genl_netdevice_event?

  reply	other threads:[~2025-04-11 17:42 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-08 19:59 [PATCH net-next v2 0/8] net: depend on instance lock for queue related netlink ops Jakub Kicinski
2025-04-08 19:59 ` [PATCH net-next v2 1/8] net: avoid potential race between netdev_get_by_index_lock() and netns switch Jakub Kicinski
2025-04-08 19:59 ` [PATCH net-next v2 2/8] net: designate XSK pool pointers in queues as "ops protected" Jakub Kicinski
2025-04-08 19:59 ` [PATCH net-next v2 3/8] netdev: add "ops compat locking" helpers Jakub Kicinski
2025-04-08 19:59 ` [PATCH net-next v2 4/8] netdev: don't hold rtnl_lock over nl queue info get when possible Jakub Kicinski
2025-04-08 19:59 ` [PATCH net-next v2 5/8] xdp: double protect netdev->xdp_flags with netdev->lock Jakub Kicinski
2025-04-08 22:15   ` Harshitha Ramamurthy
2025-04-09 18:40   ` Martin KaFai Lau
2025-04-08 19:59 ` [PATCH net-next v2 6/8] netdev: depend on netdev->lock for xdp features Jakub Kicinski
2025-04-10 17:10   ` Kuniyuki Iwashima
2025-04-11  2:10     ` Jakub Kicinski
2025-04-11  2:23       ` Jakub Kicinski
2025-04-11 17:41         ` Stanislav Fomichev [this message]
2025-04-11 19:19           ` Jakub Kicinski
2025-04-11  2:36       ` Kuniyuki Iwashima
2025-04-08 19:59 ` [PATCH net-next v2 7/8] docs: netdev: break down the instance locking info per ops struct Jakub Kicinski
2025-04-09  2:59   ` Joe Damato
2025-04-10  6:01   ` Jacob Keller
2025-04-10 16:08     ` Jakub Kicinski
2025-04-10 22:35       ` Keller, Jacob E
2025-04-10 23:39         ` Jakub Kicinski
2025-04-11 21:26           ` Jacob Keller
2025-04-08 19:59 ` [PATCH net-next v2 8/8] netdev: depend on netdev->lock for qstats in ops locked drivers Jakub Kicinski
2025-04-10  5:23   ` Jacob Keller
2025-04-10 23:46     ` Jakub Kicinski
2025-04-11 21:29       ` Jacob Keller
2025-04-10  0:40 ` [PATCH net-next v2 0/8] net: depend on instance lock for queue related netlink ops patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z_lUZgRc9JYhjnIG@mini-arch \
    --to=stfomichev@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=hramamurthy@google.com \
    --cc=jdamato@fastly.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox