syzbot
WARNING: suspicious RCU usage in phy_detach_internal
Status:
upstream: reported C repro on 2026/10/29 06:06
Subsystems:
net
usb
Labels:
prio:high
[Documentation on labels]
Reported-by: syzbot+583f42a41879bb60de32@syzkaller.appspotmail.com
First crash: 3d20h, last: 18h04m
✨ AI-generated root cause summary:
In phy_detach_internal(), dev->hwprov is accessed using rtnl_dereference(), which requires and asserts that the RTNL lock is held. However, network drivers can attach and detach PHY devices prior to net_device registration (such as during USB probe in asix/usbnet before register_netdev()), where RTNL is not held. When phylink_connect_phy() fails bringup and rolls back via phy_detach(), the absence of RTNL triggers a suspicious RCU usage warning. In a production kernel without lockdep, the pointer dereference proceeds safely and no memory corruption, leak, or denial of service occurs.
▶
▼
✨ Full AI root cause analysis
### Root Cause Analysis
#### 1. Functions, Structs, Fields, and Files Involved
- **File:** `drivers/net/phy/phy_device.c` (specifically `phy_detach_internal()`, line 1831)
- **Functions:** `phy_detach_internal()`, `phy_detach()`, `phylink_connect_phy()` (`drivers/net/phy/phylink.c`), `ax88772_init_phy()` / `ax88772_bind()` (`drivers/net/usb/asix_devices.c`), `usbnet_probe()` (`drivers/net/usb/usbnet.c`).
- **Structs & Fields:** `struct net_device::hwprov` (RCU-protected pointer to `struct hwtstamp_provider`), `struct phy_device::attached_dev`.
---
#### 2. Trigger Mechanism & Invariant Violation
1. During USB device discovery, the USB host triggers device probing via `usbnet_probe()`.
2. Before registering the network device via `register_netdev()` (so `net->reg_state` is still `NETREG_UNINITIALIZED` and RTNL lock is **not** held), `usbnet_probe()` invokes the driver-specific bind callback `ax88772_bind()`, which invokes `ax88772_init_phy()`.
3. `ax88772_init_phy()` calls `phylink_connect_phy()`, which invokes `phylink_attach_phy()` -> `phy_attach_direct()`. This succeeds and associates the network device: `phydev->attached_dev = dev`.
4. Next, `phylink_connect_phy()` calls `phylink_bringup_phy()`, which attempts to validate the PHY link modes via `phylink_validate_phy()`. When validation fails (e.g. invalid endpoint descriptors or unsupported link modes returned by the emulated USB device, returning `-EINVAL`), `phylink_connect_phy()` executes its error cleanup path and calls `phy_detach(phy)` -> `phy_detach_internal(phydev, true)`.
5. In `phy_detach_internal()`:
```c
if (dev) {
struct hwtstamp_provider *hwprov;
/* hwprov may technically be protected by ops lock but
* not for devices with a phydev, see phy_link_topo_add_phy()
*/
hwprov = rtnl_dereference(dev->hwprov);
...
```
`rtnl_dereference(dev->hwprov)` expands to `rcu_dereference_protected(dev->hwprov, lockdep_rtnl_is_held())`. Because `rtnl_lock` is not held during device probe prior to `register_netdevice()` (and drivers commonly attach/detach PHYs before registration), `lockdep_rtnl_is_held()` evaluates to false. This violates the lockdep assertion and emits:
```
WARNING: suspicious RCU usage
drivers/net/phy/phy_device.c:1831 suspicious rcu_dereference_protected() usage!
```
---
#### 3. Runtime Consequences in Production Builds
- **Lockdep/Sanitizer Disabled:** In a production kernel built without `CONFIG_PROVE_RCU` / `CONFIG_LOCKDEP`, `rtnl_dereference()` expands to `rcu_dereference_raw()` / direct pointer read without checking lock status.
- **Memory Safety & Control Flow:** At this early probe stage, `dev->hwprov` is NULL. The check `if (hwprov && hwprov->phydev == phydev)` safely evaluates to false. The subsequent cleanup (`phy_link_topo_del_phy()`, clearing references, freeing modules) proceeds normally and gracefully returns `-EINVAL` to `usbnet_probe()`.
- **Classification Justifications:**
- `MemoryCorruption: false` — No out-of-bounds access, invalid free, or use-after-free occurs; the pointer is merely read.
- `InfoLeak: "none"` — No uninitialized or kernel memory contents are exposed or leaked to user space.
- `RawDenialOfService: false` — This is a false-positive lockdep warning. In production kernels without `panic_on_warn`, no crash, hang, kernel panic, or resource leak occurs.
- `IsNetCandidate: true` — The bug occurs in Phylib (`drivers/net/phy/phy_device.c`) on `struct net_device`.
- `IsKVMCandidate: false` — The defect has no relation to virtualization or KVM.
▶
▼
Last patch testing requests (1)
Sample crash report:
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
=============================
WARNING: suspicious RCU usage
syzkaller #0 Not tainted
-----------------------------
drivers/net/phy/phy_device.c:1831 suspicious rcu_dereference_protected() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
locks held by kworker/1:2/1133: 5, last CPU#1:
#0: ffff888105ee2d48 ((wq_completion)usb_hub_wq){+.+.}-{0:0}, at: process_one_work+0x1461/0x1b10 kernel/workqueue.c:3470
#1: ffffc90002e3fd18 ((work_completion)(&hub->events)){+.+.}-{0:0}, at: process_one_work+0xa2c/0x1b10 kernel/workqueue.c:3471
#2: ffff88810b3d21d8 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1104 [inline]
#2: ffff88810b3d21d8 (&dev->mutex){....}-{4:4}, at: hub_event+0x1bb/0x4510 drivers/usb/core/hub.c:5917
#3: ffff8881135751d8 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1104 [inline]
#3: ffff8881135751d8 (&dev->mutex){....}-{4:4}, at: __device_attach+0x7e/0x4d0 drivers/base/dd.c:1073
#4: ffff888113fa31a0 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:1104 [inline]
#4: ffff888113fa31a0 (&dev->mutex){....}-{4:4}, at: __device_attach+0x7e/0x4d0 drivers/base/dd.c:1073
stack backtrace:
CPU: 1 UID: 0 PID: 1133 Comm: kworker/1:2 Not tainted syzkaller #0 PREEMPT(lazy)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/07/2026
Workqueue: usb_hub_wq hub_event
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
lockdep_rcu_suspicious.cold+0x4f/0xb2 kernel/locking/lockdep.c:6972
phy_detach_internal+0x6a5/0x830 drivers/net/phy/phy_device.c:1831
phylink_connect_phy drivers/net/phy/phylink.c:2452 [inline]
phylink_connect_phy+0x22e/0x2b0 drivers/net/phy/phylink.c:2436
ax88772_init_phy drivers/net/usb/asix_devices.c:714 [inline]
ax88772_bind+0xbb1/0x1520 drivers/net/usb/asix_devices.c:925
usbnet_probe+0xbb3/0x27e0 drivers/net/usb/usbnet.c:1812
usb_probe_interface+0x386/0x980 drivers/usb/core/driver.c:399
call_driver_probe drivers/base/dd.c:628 [inline]
really_probe+0x241/0xa60 drivers/base/dd.c:706
__driver_probe_device+0x210/0x460 drivers/base/dd.c:868
driver_probe_device+0x4a/0x140 drivers/base/dd.c:898
__device_attach_driver+0x1df/0x320 drivers/base/dd.c:1026
bus_for_each_drv+0x159/0x1e0 drivers/base/bus.c:503
__device_attach+0x1e4/0x4d0 drivers/base/dd.c:1098
device_initial_probe+0xaf/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x64/0x160 drivers/base/bus.c:623
device_add+0x121d/0x1970 drivers/base/core.c:3776
usb_set_configuration+0xd97/0x1dc0 drivers/usb/core/message.c:2279
usb_generic_driver_probe+0xa1/0xe0 drivers/usb/core/generic.c:250
usb_probe_device+0xef/0x400 drivers/usb/core/driver.c:293
call_driver_probe drivers/base/dd.c:628 [inline]
really_probe+0x241/0xa60 drivers/base/dd.c:706
__driver_probe_device+0x210/0x460 drivers/base/dd.c:868
driver_probe_device+0x4a/0x140 drivers/base/dd.c:898
__device_attach_driver+0x1df/0x320 drivers/base/dd.c:1026
bus_for_each_drv+0x159/0x1e0 drivers/base/bus.c:503
__device_attach+0x1e4/0x4d0 drivers/base/dd.c:1098
device_initial_probe+0xaf/0xd0 drivers/base/dd.c:1153
bus_probe_device+0x64/0x160 drivers/base/bus.c:623
device_add+0x121d/0x1970 drivers/base/core.c:3776
usb_new_device.part.0+0xcc2/0x1686 drivers/usb/core/hub.c:2713
usb_new_device drivers/usb/core/hub.c:5838 [inline]
hub_port_connect drivers/usb/core/hub.c:5585 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5725 [inline]
port_event drivers/usb/core/hub.c:5889 [inline]
hub_event.cold+0x51a/0xe9d drivers/usb/core/hub.c:5971
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3495
process_scheduled_works kernel/workqueue.c:3578 [inline]
worker_thread+0x5ef/0xe50 kernel/workqueue.c:3659
kthread+0x373/0x450 kernel/kthread.c:436
ret_from_fork+0x69f/0xc90 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
asix 7-1:0.188 (unnamed net_device) (uninitialized): Could not connect PHY
asix 7-1:0.188: probe with driver asix failed with error -22
usb 7-1: USB disconnect, device number 2
usb 7-1: new high-speed USB device number 3 using dummy_hcd
usb 7-1: Using ep0 maxpacket: 32
usb 7-1: New USB device found: idVendor=17ef, idProduct=7203, bcdDevice=2e.36
usb 7-1: config 0 has an invalid interface number: 188 but max is 0
usb 7-1: config 0 has no interface number 0
usb 7-1: config 0 interface 188 altsetting 0 bulk endpoint 0x82 has invalid maxpacket 32
usb 7-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 7-1: Product: syz
usb 7-1: Manufacturer: syz
usb 7-1: SerialNumber: syz
usb 7-1: config 0 descriptor??
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -32
asix 7-1:0.188 (unnamed net_device) (uninitialized): Error reading Medium Status register: ffffffe0
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable hardware MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to write reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to enable software MII access
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -71
asix 7-1:0.188 (unnamed net_device) (uninitialized): Could not connect PHY
asix 7-1:0.188: probe with driver asix failed with error -110
usb 7-1: USB disconnect, device number 3
usb 7-1: new high-speed USB device number 4 using dummy_hcd
usb 7-1: Using ep0 maxpacket: 32
usb 7-1: New USB device found: idVendor=17ef, idProduct=7203, bcdDevice=2e.36
usb 7-1: config 0 has an invalid interface number: 188 but max is 0
usb 7-1: config 0 has no interface number 0
usb 7-1: config 0 interface 188 altsetting 0 bulk endpoint 0x82 has invalid maxpacket 32
usb 7-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 7-1: Product: syz
usb 7-1: Manufacturer: syz
usb 7-1: SerialNumber: syz
usb 7-1: config 0 descriptor??
asix 7-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -32
asix 7-1:0.188: probe with driver asix failed with error -32
usb 1-1: USB disconnect, device number 4
usb 1-1: new high-speed USB device number 5 using dummy_hcd
usb 1-1: Using ep0 maxpacket: 32
usb 1-1: New USB device found: idVendor=17ef, idProduct=7203, bcdDevice=2e.36
usb 1-1: config 0 has an invalid interface number: 188 but max is 0
usb 1-1: config 0 has no interface number 0
usb 1-1: config 0 interface 188 altsetting 0 bulk endpoint 0x82 has invalid maxpacket 32
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: syz
usb 1-1: Manufacturer: syz
usb 1-1: SerialNumber: syz
usb 1-1: config 0 descriptor??
asix 1-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -32
asix 1-1:0.188 (unnamed net_device) (uninitialized): Error reading Medium Status register: ffffffe0
asix 1-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0000: -32
asix 1-1:0.188 (unnamed net_device) (uninitialized): Failed to read reg index 0x0002: -32
asix 1-1:0.188 (unnamed net_device) (uninitialized): Could not register MDIO bus (err -5)
asix 1-1:0.188: probe with driver asix failed with error -5
usb 1-1: USB disconnect, device number 5
usb 1-1: new high-speed USB device number 6 using dummy_hcd
usb 1-1: Using ep0 maxpacket: 32
usb 1-1: New USB device found: idVendor=17ef, idProduct=7203, bcdDevice=2e.36
usb 1-1: config 0 has an invalid interface number: 188 but max is 0
usb 1-1: config 0 has no interface number 0
usb 1-1: config 0 interface 188 altsetting 0 bulk endpoint 0x82 has invalid maxpacket 32
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: syz
usb 1-1: Manufacturer: syz
usb 1-1: SerialNumber: syz
usb 1-1: config 0 descriptor??
* Struck through repros no longer work on HEAD.