Thread (8 messages) 8 messages, 3 authors, 2026-03-29

Re: [PATCH] ethtool: don't touch the parent device of a net device being unregistered

From: Alexander Popov <hidden>
Date: 2026-03-22 23:08:59
Also in: lkml

On 3/22/26 17:39, Andrew Lunn wrote:
On Sun, Mar 22, 2026 at 10:59:15AM +0300, Alexander Popov wrote:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help