From: Alexander Popov <alex.popov@linux.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Jakub Kicinski <kuba@kernel.org>,
David Miller <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Michal Kubecek <mkubecek@suse.cz>, Gal Pressman <gal@nvidia.com>,
Kory Maincent <kory.maincent@bootlin.com>,
Oleksij Rempel <o.rempel@pengutronix.de>,
Ido Schimmel <idosch@nvidia.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Greg KH <gregkh@linuxfoundation.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
security@kernel.org, notify@kernel.org
Subject: Re: [PATCH] ethtool: don't touch the parent device of a net device being unregistered
Date: Mon, 23 Mar 2026 02:08:53 +0300 [thread overview]
Message-ID: <eff8cf89-fc3a-4aa1-bcfa-c939c9e7d853@linux.com> (raw)
In-Reply-To: <3c07c51a-421b-456f-9819-9021ddd7b22e@lunn.ch>
On 3/22/26 17:39, Andrew Lunn wrote:
> On Sun, Mar 22, 2026 at 10:59:15AM +0300, Alexander Popov wrote:
>> The ethtool operations may be performed on a net device that is currently
>> being unregistered. This is also described in the commit dde91ccfa25fd58f
>> ("ethtool: do not perform operations on net devices being unregistered").
>> Moreover, such a device may have a parent that has already been freed.
>
> I don't know the device core too well, but can you explain in the
> example stack trace you gave how the parent can already be free? I
> would of expected devices are arranged in a tree, and free happens
> from the leaves towards the root? In order to do a clean shutdown, you
> might need to perform operations on the parent.
>
> I just want to make sure this is not a broken parent device which
> should be fixed...
Hello Andrew, let me describe the scenario that I see:
- The netdev_run_todo() function handles the net devices in net_todo_list
in a loop and moves each of them into the NETREG_UNREGISTERED state:
netdev_lock(dev);
WRITE_ONCE(dev->reg_state, NETREG_UNREGISTERED);
netdev_unlock(dev);
- Then netdev_run_todo() frees these net devices in another loop.
On each iteration, it chooses a device for freeing:
dev = netdev_wait_allrefs_any(&list);
- At the same time, the ethnl_set_features() function calls
ethnl_parse_header_dev_get() for the child net device.
- If the race condition succeeds, ethnl_set_features() takes the reference
to the child net device being unregistered. That makes netdev_run_todo()
free the parent first.
Best regards,
Alexander
next prev parent reply other threads:[~2026-03-22 23:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-22 7:59 Alexander Popov
2026-03-22 14:39 ` Andrew Lunn
2026-03-22 23:08 ` Alexander Popov [this message]
2026-03-23 22:08 ` Jakub Kicinski
2026-03-24 18:46 ` Alexander Popov
2026-03-29 8:47 ` Alexander Popov
2026-03-29 13:52 ` Andrew Lunn
2026-03-29 17:54 ` Jakub Kicinski
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=eff8cf89-fc3a-4aa1-bcfa-c939c9e7d853@linux.com \
--to=alex.popov@linux.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=gregkh@linuxfoundation.org \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=notify@kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=security@kernel.org \
/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
all inboxes | Powered by JetHome®