[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211206071520.1fe7e18b@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Date: Mon, 6 Dec 2021 07:15:20 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Julian Wiedmann <jwi@...ux.ibm.com>
Cc: Antoine Tenart <atenart@...nel.org>, davem@...emloft.net,
alexander.duyck@...il.com, mkubecek@...e.cz, netdev@...r.kernel.org
Subject: Re: [PATCH net] ethtool: do not perform operations on net devices
being unregistered
On Mon, 6 Dec 2021 11:46:35 +0200 Julian Wiedmann wrote:
> On 03.12.21 12:13, Antoine Tenart wrote:
> > There is a short period between a net device starts to be unregistered
> > and when it is actually gone. In that time frame ethtool operations
> > could still be performed, which might end up in unwanted or undefined
> > behaviours[1].
> >
> > Do not allow ethtool operations after a net device starts its
> > unregistration. This patch targets the netlink part as the ioctl one
> > isn't affected: the reference to the net device is taken and the
> > operation is executed within an rtnl lock section and the net device
> > won't be found after unregister.
> > [...]
> > +++ b/net/ethtool/netlink.c
> > @@ -40,7 +40,8 @@ int ethnl_ops_begin(struct net_device *dev)
> > if (dev->dev.parent)
> > pm_runtime_get_sync(dev->dev.parent);
> >
> > - if (!netif_device_present(dev)) {
> > + if (!netif_device_present(dev) ||
> > + dev->reg_state == NETREG_UNREGISTERING) {
> > ret = -ENODEV;
> > goto err;
> > }
> >
>
> Wondering if other places would also benefit from a netif_device_detach()
> in the unregistration sequence ...
Sounds like a good idea but maybe as a follow up to net-next?
The likelihood of that breaking things is low, but non-zero.
Powered by blists - more mailing lists