Netdev List
 help / color / mirror / Atom feed
From: Kory Maincent <kory.maincent@bootlin.com>
To: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot+583f42a41879bb60de32@syzkaller.appspotmail.com
Subject: Re: [PATCH net] net: phy: don't require RTNL to detach a PHY from an unregistered netdev
Date: Fri, 30 Oct 2026 10:45:05 +0100	[thread overview]
Message-ID: <fefab524-d29b-4d34-a638-6ad56674b2ed@bootlin.com> (raw)
In-Reply-To: <20261029142423.93573-1-ngocthang2710.1999@gmail.com>



On 10/29/26 15:24, Nguyen Ngoc Thang wrote:
> phy_detach_internal() reads dev->hwprov with rtnl_dereference(), but
> MAC drivers commonly attach and detach PHYs while their net_device is
> not registered, without holding RTNL. Before register_netdev(), a failed
> phylink_connect_phy() or phy_attach_direct() unwinds through
> phy_detach_internal(). After unregister_netdev(), a driver's remove path
> may call phy_disconnect(). Both trip lockdep:
> 
>    WARNING: suspicious RCU usage
>    drivers/net/phy/phy_device.c:1831 suspicious rcu_dereference_protected() usage!
>     phy_detach_internal+0x6a5/0x830 drivers/net/phy/phy_device.c:1831
>     phylink_connect_phy+0x22e/0x2b0 drivers/net/phy/phylink.c:2452
>     ax88772_bind+0xbb1/0x1520 drivers/net/usb/asix_devices.c:925
>     usbnet_probe+0xbb3/0x27e0 drivers/net/usb/usbnet.c:1812
> 
> syzbot hits this with an emulated asix device. phy_eee_rx_clock_stop()
> fails on a USB MDIO error, so phylink_bringup_phy() fails and the PHY is
> detached from inside usbnet_probe(), before the netdev is registered.
> 
> hwprov is only set through ethtool, under RTNL, on a registered device.
> reg_state also changes only under RTNL. So if the device is not
> registered, no one else can reach hwprov, and RTNL is not needed. Tell
> lockdep that. A detach from a registered device without RTNL still
> warns.

Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>

Thank you!
-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com


      reply	other threads:[~2026-10-30  9:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 14:24 [PATCH net] net: phy: don't require RTNL to detach a PHY from an unregistered netdev Nguyen Ngoc Thang
2026-10-30  9:45 ` Kory Maincent [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=fefab524-d29b-4d34-a638-6ad56674b2ed@bootlin.com \
    --to=kory.maincent@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=ngocthang2710.1999@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=syzbot+583f42a41879bb60de32@syzkaller.appspotmail.com \
    /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