home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   linux.debian.kernel      Debian kernel discussions      2,884 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,949 of 2,884   
   Sam Halliday to Benjamin Tissoires   
   Bug#1122193: usb hid descriptor requirem   
   15 Dec 25 15:40:01   
   
   XPost: linux.debian.bugs.dist   
   From: sam.halliday@gmail.com   
      
   Thanks Ben,   
      
   I tried that patch and it works for me.   
      
   I'd very much like to see this backported to the 6.12 debian line and also   
   the raspberry pi 6.12 line as I'm currently having to ask my users to   
   downgrade to linux-image-6.12.25+rpt-rpi-v8 to be able to use their filter   
   wheels.   
      
      
   On Mon, 15 Dec 2025 at 12:25, Benjamin Tissoires  wrote:   
      
   > On Dec 15, 2025, Sam Halliday wrote:   
   > > Hi Ben,   
   > >   
   > > In answer to your logging request, this is the output after running   
   > >   
   > > echo 'file drivers/hid/usbhid/hid-core.c +p' | sudo tee   
   > /sys/kernel/debug/dynamic_debug/control   
   > >   
   > > and plugging in the device (with the debian kernel, not my patched one)   
   > >   
   > > [  371.897694] usb 1-2: new full-speed USB device number 8 using xhci_hcd   
   > > [  372.036133] usb 1-2: New USB device found, idVendor=03c3,   
   > idProduct=1f01, bcdDevice= 0.00   
   > > [  372.036145] usb 1-2: New USB device strings: Mfr=1, Product=2,   
   > SerialNumber=0   
   > > [  372.036149] usb 1-2: Product: ZWO EFW   
   > > [  372.036152] usb 1-2: Manufacturer: ZW0   
   > > [  372.043375] drivers/hid/usbhid/hid-core.c: HID probe called for ifnum   
   > 0   
   > > [  372.043404] drivers/hid/usbhid/hid-core.c: hid descriptor invalid,   
   > bLen=9 bNum=2   
   >   
   > Looks like the length is shorter than expected. However, after looking   
   > more carefully into the code, it seems we can bypass the check as long   
   > as the provided length is greater than sizeof(*hdesc), because later in   
   > the code we simply ignore any optional HID class descriptors.   
   >   
   > Would you mind testing the following patch?:   
   >   
   > ---   
   > From 07020d68764a29a9e5d4e95be1820e0c75a4216a Mon Sep 17 00:00:00 2001   
   > From: Benjamin Tissoires    
   > Date: Mon, 15 Dec 2025 12:57:21 +0100   
   > Subject: [PATCH] HID: usbhid: paper over wrong bNumDescriptor field   
   >   
   > Some faulty devices (ZWO EFWmini) have a wrong optional HID class   
   > descriptor count compared to the provided length.   
   >   
   > Given that we plainly ignore those optional descriptor, we can attempt   
   > to fix the provided number so we do not lock out those devices.   
   >   
   > Signed-off-by: Benjamin Tissoires    
   > ---   
   >  drivers/hid/usbhid/hid-core.c | 17 ++++++++++++++++-   
   >  1 file changed, 16 insertions(+), 1 deletion(-)   
   >   
   > diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c   
   > index aac0051a2cf6..758eb21430cd 100644   
   > --- a/drivers/hid/usbhid/hid-core.c   
   > +++ b/drivers/hid/usbhid/hid-core.c   
   > @@ -985,6 +985,7 @@ static int usbhid_parse(struct hid_device *hid)   
   >         struct usb_device *dev = interface_to_usbdev (intf);   
   >         struct hid_descriptor *hdesc;   
   >         struct hid_class_descriptor *hcdesc;   
   > +       __u8 fixed_opt_descriptors_size;   
   >         u32 quirks = 0;   
   >         unsigned int rsize = 0;   
   >         char *rdesc;   
   > @@ -1015,7 +1016,21 @@ static int usbhid_parse(struct hid_device *hid)   
   >                               (hdesc->bNumDescriptors - 1) *   
   > sizeof(*hcdesc)) {   
   >                 dbg_hid("hid descriptor invalid, bLen=%hhu bNum=%hhu\n",   
   >                         hdesc->bLength, hdesc->bNumDescriptors);   
   > -               return -EINVAL;   
   > +   
   > +               /*   
   > +                * Some devices may expose a wrong number of descriptors   
   > compared   
   > +                * to the provided length.   
   > +                * However, we ignore the optional hid class descriptors   
   > entirely   
   > +                * so we can safely recompute the proper field.   
   > +                */   
   > +               if (hdesc->bLength >= sizeof(*hdesc)) {   
   > +                       fixed_opt_descriptors_size = hdesc->bLength -   
   > sizeof(*hdesc);   
   > +   
   > +                       hid_warn(intf, "fixing wrong optional hid class   
   > descriptors count\n");   
   > +                       hdesc->bNumDescriptors =   
   > fixed_opt_descriptors_size / sizeof(*hcdesc) + 1;   
   > +               } else {   
   > +                       return -EINVAL;   
   > +               }   
   >         }   
   >   
   >         hid->version = le16_to_cpu(hdesc->bcdHID);   
   > --   
   > 2.51.1   
   >   
   > ---   
   >   
   > Cheers,   
   > Benjamin   
   >   
   > > [  372.043409] usbhid 1-2:1.0: can't add hid device: -22   
   > > [  372.043422] usbhid 1-2:1.0: probe with driver usbhid failed with   
   > error -22   
   > >   
   > > Also here is a more detailed lsusb output   
   > >   
   > >   
   > > Bus 001 Device 008: ID 03c3:1f01 ZWO ZWO EFW   
   > > Negotiated speed: Full Speed (12Mbps)   
   > > Device Descriptor:   
   > >   bLength                18   
   > >   bDescriptorType         1   
   > >   bcdUSB               1.10   
      
   [continued in next message]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca