[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANn89iLQeLPegmtqJ09vFs0QVAqFaf5Hy3P7agfqU0tvCXBsOw@mail.gmail.com>
Date: Thu, 29 Jan 2026 16:13:14 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: Vladimir Oltean <olteanv@...il.com>
Cc: Andrew Lunn <andrew@...n.ch>, netdev <netdev@...r.kernel.org>,
Paolo Abeni <pabeni@...hat.com>, Jakub Kicinski <kuba@...nel.org>
Subject: Re: [BUG dsa] lack of barriers in netdev_uses_dsa()
On Thu, Jan 29, 2026 at 4:05 PM Vladimir Oltean <olteanv@...il.com> wrote:
>
> Hi Eric,
>
> On Thu, Jan 29, 2026 at 02:16:56PM +0100, Eric Dumazet wrote:
> > Hi dsa experts
> >
> > It seems netdev_uses_dsa() does not have any barrier.
> >
> > A compiler could read dev->dsa_ptr and get a NULL the second time.
> >
> > include/net/dsa.h:1336:static inline bool netdev_uses_dsa(const struct
> > net_device *dev)
> > include/net/dsa.h-1337-{
> > include/net/dsa.h-1338-#if IS_ENABLED(CONFIG_NET_DSA)
> > include/net/dsa.h-1339- return dev->dsa_ptr && dev->dsa_ptr->rcv;
> > include/net/dsa.h-1340-#endif
> > include/net/dsa.h-1341- return false;
> > include/net/dsa.h-1342-}
> >
> > I was looking at this because I wanted to inline eth_type_trans().
> >
> > Note the wmb() in dsa_conduit_teardown(), which is not good enough.
> >
> > Any suggestions?
> >
> > Ideally, it would be nice if netdev_uses_dsa() could test a single bit
> > in "struct net_device",
> > without a dereference of dsa_ptr.
> >
> > Thanks.
>
> It's been like this for a really long time.
>
> Alexander Sverdlin had a patch to convert dev->dsa_ptr to RCU/RTNL
> protection, but his problem ended up being solved in a simpler way:
> https://lore.kernel.org/netdev/20240910130321.337154-1-alexander.sverdlin@siemens.com/
>
> I also started working a while ago on some patches to gradually replace
> netdev_uses_dsa() with one of
> netdev_uses_dsa_rcu()
> netdev_uses_dsa_rcu_bh()
> netdev_uses_dsa_rtnl()
> https://github.com/vladimiroltean/linux/blob/dsa-rcu-rtnl-my-try-v1/include/net/dsa.h#L1360
>
> but I didn't submit anything and I almost forgot about that patch set.
>
> How urgent is this?
This is not urgent, thank you for the quick answer.
Although using rcu from eth_type_trans() seems overkill (on builds
where rcu_read_lock() and rcu_read_unlock() are not NOP)
If ETH_P_XDSA is returned from eth_type_trans(), another rcu and
rcu_dereference() will be needed later.
Powered by blists - more mailing lists