net:usb:r8152: remove WARN_ON_ONCE() in rtl_vendor_mode()
Subsystems (3)
PATCH 1/1 net:usb:r8152: remove WARN_ON_ONCE() in rtl_vendor_mode()
If from the userland, a dummy_udc (a virtual USB device for debugging/device emulation) is configured to have a VENDOR_ID/PRODUCT_ID combination that is supported by rtl8152 driver, and kernel tries to match this dummy device with rtl8152 driver by probing, the rtl8152_probe() function will cause WARN_ON_ONCE() in rtl_vendor_mode(). This causes kernel panic if panic_on_warn is set.
More specifically, this WARN_ON_ONCE() is triggered when the rtl8152 driver detects (and trys to switch on) the vendor specific USB configuration, which is an expected behavior for supported USB devices. Rtl8152 should also anticipate dummy_udc which can have arbitrary configurations and interfaces.
Remove this WARN_ON_ONCE() so that rtl8152 is able to handle (or gracefully refuse) an unsupported USB device during probing.
Bug reported by syzbot:
https://syzkaller.appspot.com/bug?id=912c9c373656996801b4de61f1e3cb326fe940aa
VENDOR_ID/PRODUCT_ID in question:REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927)
---
This patch passed syzbot test.
drivers/net/usb/r8152.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/usb/r8152.c +0 -2
@@ -8135,8 +8135,6 @@ static bool rtl_vendor_mode(struct usb_interface *intf) } } -WARN_ON_ONCE (i == num_configs); -return false; }
Signature · 1 line
2.30.2
Du Cheng <[email protected]>
Quoted 1 line
Sent: Saturday, May 15, 2021 10:25 PM
[...]
Quoted 21 lines
If from the userland, a
dummy_udc(a virtual USB device for debugging/device emulation) is configured to have a VENDOR_ID/PRODUCT_ID
combination that is supported by rtl8152 driver, and kernel tries to match this dummy device with rtl8152 driver by probing, thertl8152_probe()function will causeWARN_ON_ONCE()inrtl_vendor_mode(). This causes kernel panic ifpanic_on_warnis set.More specifically, this
WARN_ON_ONCE()is triggered when the rtl8152 driver detects (and trys to switch on) the vendor specific USB configuration, which is an expected behavior for supported USB devices. Rtl8152 should also anticipatedummy_udcwhich can have arbitrary configurations and interfaces.Remove this
WARN_ON_ONCE()so that rtl8152 is able to handle (or gracefully refuse) an unsupported USB device during probing.Bug reported by syzbot:
https://syzkaller.appspot.com/bug?id=912c9c373656996801b4de61f1e3cb326f
e940aa
Quoted 5 lines
VENDOR_ID/PRODUCT_ID in question:
REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927)Reported-by [email protected]Signed-off-by Du Cheng <[email protected]>