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>,
Johannes Berg <johannes@sipsolutions.net>,
James Guan <guan_yufei@163.com>, Kees Cook <kees@kernel.org>,
Paul Moses <p@1g4.org>,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, security@kernel.org,
notify@kernel.org
Subject: Re: [PATCH] wifi: virt_wifi: remove SET_NETDEV_DEV to avoid use-after-free
Date: Wed, 25 Mar 2026 20:24:42 +0300 [thread overview]
Message-ID: <76bba9e1-1e87-413e-94d7-80e7c352a55b@linux.com> (raw)
In-Reply-To: <fa3c91c3-9ceb-4fb2-9250-cc239fb0c1b6@lunn.ch>
On 3/25/26 15:34, Andrew Lunn wrote:
> On Wed, Mar 25, 2026 at 01:46:02AM +0300, Alexander Popov wrote:
>> Currently we execute `SET_NETDEV_DEV(dev, &priv->lowerdev->dev)` for
>> the virt_wifi net devices. However, unregistering a virt_wifi device in
>> netdev_run_todo() can happen together with the device referenced by
>> SET_NETDEV_DEV().
>>
>> It can result in use-after-free during the ethtool operations performed
>> on a virt_wifi device that is currently being unregistered. Such a net
>> device can have the `dev.parent` field pointing to the freed memory,
>> but ethnl_ops_begin() calls `pm_runtime_get_sync(dev->dev.parent)`.
>>
>> Let's remove SET_NETDEV_DEV for virt_wifi to avoid bugs like this:
>
> Did you have a look at all user of SET_NETDEV_DEV() to see if there
> are other examples of the same bug?
>
> What i found was:
>
> https://elixir.bootlin.com/linux/v6.19.9/source/drivers/net/ethernet/mellanox/mlx4/en_netdev.c#L3180
>
> Does this have the same problem?
Andrew, I can't say about this particular net device. Looks like it refers to a
specific ethernet adapter.
How can we distinguish security-relevant bugs similar to this use-after-free:
an unprivileged user must be able to create a given net device via user namespaces.
As I mentioned, applying this fix in ethtool could help against them:
https://lore.kernel.org/all/20260322075917.254874-1-alex.popov@linux.com/T/#u
Best regards,
Alexander
prev parent reply other threads:[~2026-03-25 17:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 22:46 [PATCH] wifi: virt_wifi: remove SET_NETDEV_DEV to avoid use-after-free Alexander Popov
2026-03-25 8:35 ` Greg KH
2026-03-25 9:23 ` Breno Leitao
2026-03-25 12:34 ` Andrew Lunn
2026-03-25 13:47 ` Greg KH
2026-03-25 17:24 ` Alexander Popov [this message]
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=76bba9e1-1e87-413e-94d7-80e7c352a55b@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=guan_yufei@163.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=johannes@sipsolutions.net \
--cc=kees@kernel.org \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@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=p@1g4.org \
--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