usb: core: add USB_QUIRK_CONFIG_DESC_READ_255 for Razer BlackShark V3 Pro
Subsystems (3)
PATCH 1/1 usb: core: add USB_QUIRK_CONFIG_DESC_READ_255 for Razer BlackShark V3 Pro
From: Charles D'Aoust <[email protected]>
The Razer BlackShark V3 Pro wireless headset dongle (1532:0577) fingerprints its host during the first enumeration after power-on: if the first GET_DESCRIPTOR(CONFIGURATION) request asks for 255 bytes, as Windows does, the dongle enables its vendor HID command channel; if it sees the 9-byte header-only read that Linux issues, it disables that channel for the rest of the power session. Audio still works in that state, but battery reporting and all vendor commands are silently ignored, and nothing short of removing power recovers the device:
resets, re-enumerations and byte-exact replays of complete Windows control sessions were all verified not to help.
Both read lengths are spec-compliant (the device truncates the reply to wLength); the firmware was evidently only validated against the larger request. The kernel already accommodates this class of firmware assumption during enumeration: hub_port_init() reads the device descriptor with a 64-byte request because that is what Windows does and what many devices expect.
Add USB_QUIRK_CONFIG_DESC_READ_255, which makes usb_get_configuration() request 255 bytes for the initial configuration descriptor read rather than USB_DT_CONFIG_SIZE, apply it to 1532:0577, and expose it as runtime quirk letter 'r'. Devices without the quirk are unaffected.
The trigger was isolated by single-variable bisection on otherwise unmodified kernels: with only the widened initial read, the dongle's vendor channel comes up enabled on a cold plug with no interface drivers bound (bare enumeration only); without it, it never does.
--- Documentation/admin-guide/kernel-parameters.txt | 3 +++ drivers/usb/core/config.c | 13 ++++++++++--- drivers/usb/core/quirks.c | 6 ++++++ include/linux/usb/quirks.h | 3 +++ 4 files changed, 22 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +3 -0
@@ -8169,6 +8169,9 @@ Kernel parameters q = USB_QUIRK_FORCE_ONE_CONFIG (Device claims zero configurations, forcing to 1); + r = USB_QUIRK_CONFIG_DESC_READ_255 (initial + configuration descriptor read must + request 255 bytes, as Windows does); Example: quirks=0781:5580:bk,0a5c:5834:gij usbhid.mousepoll=
drivers/usb/core/config.c +10 -3
@@ -908,7 +908,7 @@ int usb_get_configuration(struct usb_device *dev) {struct device *ddev = &dev->dev;int ncfg = dev->descriptor.bNumConfigurations; -unsigned int cfgno, length; +unsigned int cfgno, length, first_read_len;unsigned char *bigbuffer;struct usb_config_descriptor *desc;int result;
@@ -938,7 +938,14 @@ int usb_get_configuration(struct usb_device *dev)if (!dev->rawdescriptors)return -ENOMEM ; - desc =kmalloc (USB_DT_CONFIG_SIZE ,GFP_KERNEL ); +/* +* Some devices (see USB_QUIRK_CONFIG_DESC_READ_255) malfunction unless +* the initial configuration descriptor read requests 255 bytes, as +* Windows does. Only the header is consumed here either way. +*/ + first_read_len = (dev->quirks &USB_QUIRK_CONFIG_DESC_READ_255 ) ? +255 :USB_DT_CONFIG_SIZE ; + desc =kmalloc (first_read_len,GFP_KERNEL );if (!desc)return -ENOMEM ;
@@ -946,7 +953,7 @@ int usb_get_configuration(struct usb_device *dev)/* We grab just the first descriptor so we know how long * the whole configuration is */ result =usb_get_descriptor (dev,USB_DT_CONFIG , cfgno, - desc,USB_DT_CONFIG_SIZE ); + desc, first_read_len);if (result <0 ) {dev_err (ddev,"unable to read config index %d " "descriptor/%s: %d\n" , cfgno,"start" , result);
drivers/usb/core/quirks.c +6 -0
@@ -142,6 +142,9 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)break ;case 'q' : flags |=USB_QUIRK_FORCE_ONE_CONFIG ; +break ; +case 'r' : + flags |=USB_QUIRK_CONFIG_DESC_READ_255 ;/* Ignore unrecognized flag characters */ } }
@@ -496,6 +499,9 @@ static const struct usb_device_id usb_quirk_list[] = {/* Razer - Razer Blade Keyboard */ { USB_DEVICE(0x1532, 0x0116), .driver_info = USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, + /* Razer - Razer BlackShark V3 Pro wireless headset dongle */ + { USB_DEVICE(0x1532, 0x0577), .driver_info = + USB_QUIRK_CONFIG_DESC_READ_255 }, /* Razer - Razer Kiyo Pro Webcam */ { USB_DEVICE(0x1532, 0x0e05), .driver_info = USB_QUIRK_NO_LPM },
include/linux/usb/quirks.h +3 -0
@@ -81,4 +81,7 @@/* Device claims zero configurations, forcing to 1 */ #define USB_QUIRK_FORCE_ONE_CONFIG BIT(18) +/* initial configuration descriptor read must request 255 bytes (Windows) */ +#define USB_QUIRK_CONFIG_DESC_READ_255 BIT(19) +#endif /* __LINUX_USB_QUIRKS_H */
Signature · 1 line
2.55.0
Quoted 25 lines · Charles Daoust
From: Charles D'Aoust <[email protected]>
The Razer BlackShark V3 Pro wireless headset dongle (1532:0577) fingerprints its host during the first enumeration after power-on: if the first
GET_DESCRIPTOR(CONFIGURATION)request asks for 255 bytes, as Windows does, the dongle enables its vendor HID command channel; if it sees the 9-byte header-only read that Linux issues, it disables that channel for the rest of the power session. Audio still works in that state, but battery reporting and all vendor commands are silently ignored, and nothing short of removing power recovers the device:
resets, re-enumerations and byte-exact replays of complete Windows control sessions were all verified not to help.Both read lengths are spec-compliant (the device truncates the reply to wLength); the firmware was evidently only validated against the larger request. The kernel already accommodates this class of firmware assumption during enumeration:
hub_port_init()reads the device descriptor with a 64-byte request because that is what Windows does and what many devices expect.Add
USB_QUIRK_CONFIG_DESC_READ_255, which makesusb_get_configuration()request 255 bytes for the initial configuration descriptor read rather thanUSB_DT_CONFIG_SIZE, apply it to 1532:0577, and expose it as runtime quirk letter 'r'. Devices without the quirk are unaffected.
Quoted 8 lines
The trigger was isolated by single-variable bisection on otherwise unmodified kernels: with only the widened initial read, the dongle's vendor channel comes up enabled on a cold plug with no interface drivers bound (bare enumeration only); without it, it never does.
Signed-off-by Charles D'Aoust <[email protected]>---
Is this not the same as
https://lore.kernel.org/linux-usb/[email protected]/
?
Alan Stern
Quoted 98 lines
Documentation/admin-guide/kernel-parameters.txt | 3 +++ drivers/usb/core/config.c | 13 ++++++++++--- drivers/usb/core/quirks.c | 6 ++++++ include/linux/usb/quirks.h | 3 +++ 4 files changed, 22 insertions(+), 3 deletions(-)Documentation/admin-guide/kernel-parameters.txt +3
-0@@ -8169,6 +8169,9 @@ Kernel parameters q = USB_QUIRK_FORCE_ONE_CONFIG (Device claims zero configurations, forcing to 1); + r = USB_QUIRK_CONFIG_DESC_READ_255 (initial + configuration descriptor read must + request 255 bytes, as Windows does); Example: quirks=0781:5580:bk,0a5c:5834:gij usbhid.mousepoll=drivers/usb/core/config.c +10
-3@@ -908,7 +908,7 @@ int usb_get_configuration(struct usb_device *dev) {struct device *ddev = &dev->dev;int ncfg = dev->descriptor.bNumConfigurations; -unsigned int cfgno, length; +unsigned int cfgno, length, first_read_len;unsigned char *bigbuffer;struct usb_config_descriptor *desc;int result;@@ -938,7 +938,14 @@ int usb_get_configuration(struct usb_device *dev)if (!dev->rawdescriptors)return -ENOMEM ; - desc =kmalloc (USB_DT_CONFIG_SIZE ,GFP_KERNEL ); +/* +* Some devices (see USB_QUIRK_CONFIG_DESC_READ_255) malfunction unless +* the initial configuration descriptor read requests 255 bytes, as +* Windows does. Only the header is consumed here either way. +*/ + first_read_len = (dev->quirks &USB_QUIRK_CONFIG_DESC_READ_255 ) ? +255 :USB_DT_CONFIG_SIZE ; + desc =kmalloc (first_read_len,GFP_KERNEL );if (!desc)return -ENOMEM ;@@ -946,7 +953,7 @@ int usb_get_configuration(struct usb_device *dev)/* We grab just the first descriptor so we know how long * the whole configuration is */ result =usb_get_descriptor (dev,USB_DT_CONFIG , cfgno, - desc,USB_DT_CONFIG_SIZE ); + desc, first_read_len);if (result <0 ) {dev_err (ddev,"unable to read config index %d " "descriptor/%s: %d\n" , cfgno,"start" , result);drivers/usb/core/quirks.c +6
-0@@ -142,6 +142,9 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)break ;case 'q' : flags |=USB_QUIRK_FORCE_ONE_CONFIG ; +break ; +case 'r' : + flags |=USB_QUIRK_CONFIG_DESC_READ_255 ;/* Ignore unrecognized flag characters */ } }@@ -496,6 +499,9 @@ static const struct usb_device_id usb_quirk_list[] = {/* Razer - Razer Blade Keyboard */ { USB_DEVICE(0x1532, 0x0116), .driver_info = USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, + /* Razer - Razer BlackShark V3 Pro wireless headset dongle */ + { USB_DEVICE(0x1532, 0x0577), .driver_info = + USB_QUIRK_CONFIG_DESC_READ_255 }, /* Razer - Razer Kiyo Pro Webcam */ { USB_DEVICE(0x1532, 0x0e05), .driver_info = USB_QUIRK_NO_LPM },include/linux/usb/quirks.h +3
-0@@ -81,4 +81,7 @@/* Device claims zero configurations, forcing to 1 */ #define USB_QUIRK_FORCE_ONE_CONFIG BIT(18) +/* initial configuration descriptor read must request 255 bytes (Windows) */ +#define USB_QUIRK_CONFIG_DESC_READ_255 BIT(19) +#endif /* __LINUX_USB_QUIRKS_H */ Signature · 1 line
2.55.0
You are correct, they are indeed the same. I apologize, I missed it.
---
Charles D’Aoust
---
Charles D’Aoust
Quoted 142 lines · Alan Stern
Quoted 25 lines · Charles Daoust
From: Charles D'Aoust <[email protected]>
The Razer BlackShark V3 Pro wireless headset dongle (1532:0577) fingerprints its host during the first enumeration after power-on: if the first
GET_DESCRIPTOR(CONFIGURATION)request asks for 255 bytes, as Windows does, the dongle enables its vendor HID command channel; if it sees the 9-byte header-only read that Linux issues, it disables that channel for the rest of the power session. Audio still works in that state, but battery reporting and all vendor commands are silently ignored, and nothing short of removing power recovers the device:
resets, re-enumerations and byte-exact replays of complete Windows control sessions were all verified not to help.Both read lengths are spec-compliant (the device truncates the reply to wLength); the firmware was evidently only validated against the larger request. The kernel already accommodates this class of firmware assumption during enumeration:
hub_port_init()reads the device descriptor with a 64-byte request because that is what Windows does and what many devices expect.Add
USB_QUIRK_CONFIG_DESC_READ_255, which makesusb_get_configuration()request 255 bytes for the initial configuration descriptor read rather thanUSB_DT_CONFIG_SIZE, apply it to 1532:0577, and expose it as runtime quirk letter 'r'. Devices without the quirk are unaffected.Quoted 8 lines
The trigger was isolated by single-variable bisection on otherwise unmodified kernels: with only the widened initial read, the dongle's vendor channel comes up enabled on a cold plug with no interface drivers bound (bare enumeration only); without it, it never does.
Signed-off-by Charles D'Aoust <[email protected]>---
Is this not the same as
https://lore.kernel.org/linux-usb/[email protected]/
?
Alan Stern
Quoted 98 lines
Documentation/admin-guide/kernel-parameters.txt | 3 +++ drivers/usb/core/config.c | 13 ++++++++++--- drivers/usb/core/quirks.c | 6 ++++++ include/linux/usb/quirks.h | 3 +++ 4 files changed, 22 insertions(+), 3 deletions(-)Documentation/admin-guide/kernel-parameters.txt +3
-0@@ -8169,6 +8169,9 @@ Kernel parameters q = USB_QUIRK_FORCE_ONE_CONFIG (Device claims zero configurations, forcing to 1); + r = USB_QUIRK_CONFIG_DESC_READ_255 (initial + configuration descriptor read must + request 255 bytes, as Windows does); Example: quirks=0781:5580:bk,0a5c:5834:gij usbhid.mousepoll=drivers/usb/core/config.c +10
-3@@ -908,7 +908,7 @@ int usb_get_configuration(struct usb_device *dev) {struct device *ddev = &dev->dev;int ncfg = dev->descriptor.bNumConfigurations; -unsigned int cfgno, length; +unsigned int cfgno, length, first_read_len;unsigned char *bigbuffer;struct usb_config_descriptor *desc;int result;@@ -938,7 +938,14 @@ int usb_get_configuration(struct usb_device *dev)if (!dev->rawdescriptors)return -ENOMEM ; - desc =kmalloc (USB_DT_CONFIG_SIZE ,GFP_KERNEL ); +/* +* Some devices (see USB_QUIRK_CONFIG_DESC_READ_255) malfunction unless +* the initial configuration descriptor read requests 255 bytes, as +* Windows does. Only the header is consumed here either way. +*/ + first_read_len = (dev->quirks &USB_QUIRK_CONFIG_DESC_READ_255 ) ? +255 :USB_DT_CONFIG_SIZE ; + desc =kmalloc (first_read_len,GFP_KERNEL );if (!desc)return -ENOMEM ;@@ -946,7 +953,7 @@ int usb_get_configuration(struct usb_device *dev)/* We grab just the first descriptor so we know how long * the whole configuration is */ result =usb_get_descriptor (dev,USB_DT_CONFIG , cfgno, - desc,USB_DT_CONFIG_SIZE ); + desc, first_read_len);if (result <0 ) {dev_err (ddev,"unable to read config index %d " "descriptor/%s: %d\n" , cfgno,"start" , result);drivers/usb/core/quirks.c +6
-0@@ -142,6 +142,9 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)break ;case 'q' : flags |=USB_QUIRK_FORCE_ONE_CONFIG ; +break ; +case 'r' : + flags |=USB_QUIRK_CONFIG_DESC_READ_255 ;/* Ignore unrecognized flag characters */ } }@@ -496,6 +499,9 @@ static const struct usb_device_id usb_quirk_list[] = {/* Razer - Razer Blade Keyboard */ { USB_DEVICE(0x1532, 0x0116), .driver_info = USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, + /* Razer - Razer BlackShark V3 Pro wireless headset dongle */ + { USB_DEVICE(0x1532, 0x0577), .driver_info = + USB_QUIRK_CONFIG_DESC_READ_255 }, /* Razer - Razer Kiyo Pro Webcam */ { USB_DEVICE(0x1532, 0x0e05), .driver_info = USB_QUIRK_NO_LPM },include/linux/usb/quirks.h +3
-1@@ -81,4 +81,7 @@/* Device claims zero configurations, forcing to 1 */ #define USB_QUIRK_FORCE_ONE_CONFIG BIT(18) +/* initial configuration descriptor read must request 255 bytes (Windows) */ +#define USB_QUIRK_CONFIG_DESC_READ_255 BIT(19) +#endif /* __LINUX_USB_QUIRKS_H */ --2.55.0
Quoted 13 lines · Charles Daoust
From: Charles D'Aoust <[email protected]>
The Razer BlackShark V3 Pro wireless headset dongle (1532:0577) fingerprints its host during the first enumeration after power-on: if the first
GET_DESCRIPTOR(CONFIGURATION)request asks for 255 bytes, as Windows does, the dongle enables its vendor HID command channel; if it sees the 9-byte header-only read that Linux issues, it disables that channel for the rest of the power session. Audio still works in that state, but battery reporting and all vendor commands are silently ignored, and nothing short of removing power recovers the device:
resets, re-enumerations and byte-exact replays of complete Windows control sessions were all verified not to help.
Quoted 3 lines
Both read lengths are spec-compliant (the device truncates the reply to wLength); the firmware was evidently only validated against the larger request.
Hmm, so is it fingerprinting of the host or sloppy QA? ;) Out of curiosity, was this patch AI-generated?
Quoted 10 lines
The kernel already accommodates this class of
firmware assumption during enumeration:hub_port_init()reads the device descriptor with a 64-byte request because that is what Windows does and what many devices expect.Add
USB_QUIRK_CONFIG_DESC_READ_255, which makesusb_get_configuration()request 255 bytes for the initial configuration descriptor read rather thanUSB_DT_CONFIG_SIZE, apply it to 1532:0577, and expose it as runtime quirk letter 'r'. Devices without the quirk are unaffected.
Quoted 7 lines
The trigger was isolated by single-variable bisection on otherwise unmodified kernels: with only the widened initial read, the dongle's vendor channel comes up enabled on a cold plug with no interface drivers bound (bare enumeration only); without it, it never does.
Signed-off-by Charles D'Aoust <[email protected]>
But anyway, FYI an equivalent quirk is now sitting in Greg KH's queue of fixes for (presumably) the 7.2 release.
I suspect that Greg would accept one more patch to enable the quirk by default on your device ID.
Regards,
Michal
It was indeed AI assisted. It's hard to tell if this is sloppy QA, obviously, but initially I thought it was an actual lockdown in the firmware to prevent non-Razer software from accessing the device. Turns out you're probably right.
---
Charles D’Aoust
Quoted 48 lines · Michal Pecio
Quoted 13 lines · Charles Daoust
From: Charles D'Aoust <[email protected]>
The Razer BlackShark V3 Pro wireless headset dongle (1532:0577) fingerprints its host during the first enumeration after power-on: if the first
GET_DESCRIPTOR(CONFIGURATION)request asks for 255 bytes, as Windows does, the dongle enables its vendor HID command channel; if it sees the 9-byte header-only read that Linux issues, it disables that channel for the rest of the power session. Audio still works in that state, but battery reporting and all vendor commands are silently ignored, and nothing short of removing power recovers the device:
resets, re-enumerations and byte-exact replays of complete Windows control sessions were all verified not to help.Quoted 3 lines
Both read lengths are spec-compliant (the device truncates the reply to wLength); the firmware was evidently only validated against the larger request.
Hmm, so is it fingerprinting of the host or sloppy QA? ;) Out of curiosity, was this patch AI-generated?
Quoted 10 lines
The kernel already accommodates this class of
firmware assumption during enumeration:hub_port_init()reads the device descriptor with a 64-byte request because that is what Windows does and what many devices expect.Add
USB_QUIRK_CONFIG_DESC_READ_255, which makesusb_get_configuration()request 255 bytes for the initial configuration descriptor read rather thanUSB_DT_CONFIG_SIZE, apply it to 1532:0577, and expose it as runtime quirk letter 'r'. Devices without the quirk are unaffected.Quoted 7 lines
The trigger was isolated by single-variable bisection on otherwise unmodified kernels: with only the widened initial read, the dongle's vendor channel comes up enabled on a cold plug with no interface drivers bound (bare enumeration only); without it, it never does.
Signed-off-by Charles D'Aoust <[email protected]>But anyway, FYI an equivalent quirk is now sitting in Greg KH's queue of fixes for (presumably) the 7.2 release.
I suspect that Greg would accept one more patch to enable the quirk by default on your device ID.
Regards,
Michal