Subject: Re: [PATCH net] net: avoid race between device unregistration and set_channels

From: Edward Cree <[email-masked]>
Date: Tue, 14 Jan 2025 10:09:07 +0000

On 13/01/2025 16:18, Antoine Tenart wrote:
> This is because unregister_netdevice_many_notify might run before
> set_channels (both are under rtnl). When that happens, the rss lock is
> being destroyed before being used again. Fix this by destroying the rss
> lock in run_todo, outside an rtnl lock section and after all references
> to net devices are gone.

The latter (refs gone) being the important part?  Doesn't seem
 particularly relevant that we've dropped rtnl, this wording had me
 confused for a little while as to why this closed the race.

> Note that allowing to run set_channels after the rtnl section of the
> unregistration path should be fine as it still runs before the
> destructors (thanks to refcount). This patch does not change that.
> 
> Fixes: 87925151191b ("net: ethtool: add a mutex protecting RSS contexts")
> Cc: Edward Cree <[email-masked]>
> Signed-off-by: Antoine Tenart <[email-masked]>

Reviewed-by: Edward Cree <[email-masked]>