Ticket #48 (closed defect: fixed)

Opened 3 years ago

Last modified 18 months ago

windows_usb.c - Incorrect Configuration Descriptor Assumption

Reported by: benjamin dobell Owned by: pbatard
Milestone: Component: libusb-1.0
Keywords: windows_usb.c, libusb_config_descriptor Cc:
Blocked By: Blocks:

Description

// Sanity check. Ensures that indexes for our list of config desc is in the right order
if (i != (cd_data->bConfigurationValue-1))
{
	usbi_warn(ctx, "program assertion failed - config descriptors are being read out of order");
	continue;
}

The above is incorrect and should be removed from windows_usb.c as it is possible to install the libusb driver for a component device as well is its interfaces.

Change History

comment:1 Changed 3 years ago by timrprobocom

The description of the issue is wrong, although the problem is quite real and the code should be deleted. Unlike interface numbers, configuration values are not required to be either sequential or contiguous. The bConfigurationValue byte is just a key, not an array index. It is quite legal for me to have three configurations, in order, with bConfigurationValue set to 99, 16 and 42.

comment:2 Changed 3 years ago by pbatard

There are 2 issues at hand here:

  1. If your goal in removing this section is to install the WinUSB driver as the Windows composite parent driver, which is what I assume you mean by component device, then you won't be able to use the interfaces at all. This is a limitation of WinUSB (because the WinUsb_GetAssociatedInterface() call cannot be used in that fashion) and the main reason why you should not attempt to use WinUSB as the composite parent driver (usbccgp), but only for its composite interfaces.
  2. Removing the section alone is expected to crash libusb. Some extra code needs to be added, which we will start working on.

comment:3 Changed 3 years ago by pbatard

  • Owner set to pbatard
  • Status changed from new to accepted

comment:4 Changed 3 years ago by pbatard

  • Resolution set to fixed
  • Status changed from accepted to closed

Should be fixed in pbr294 (actual fix was very close to what Benjamin described)

Now, while WinUsb_GetAssociatedInterface() indeed works for composite parent devices unlike what we reported earlier, the actual limitation seems to be that WinUsb_QueryInterfaceSettings() only returns the interface settings from the first interface, no matter what interface handle it is being fed.

comment:5 Changed 3 years ago by stuge

  • Resolution fixed deleted
  • Status changed from closed to reopened

Please don't close until fixed in libusb.git.

comment:6 Changed 18 months ago by pbatard

  • Resolution set to fixed
  • Status changed from reopened to closed

In [9c8e6545f2fbb171f81a9451eaf2d09e1fbc13b3/libusb]:

Windows: Allow arbitrary bConfigurationValue in config descriptors

Unlike bInterfaceNumber, bConfigurationValue does not have to be
either sequential or contiguous. The bConfigurationValue is now
included in debug output. Fixes #48 reported by Benjamin Dobell.

comment:7 Changed 18 months ago by pbatard

In [24494ed5db27737fc607fc35dda722521c9fe4d4/libusb]:

Windows: Allow claiming any interface in composite device using WinUSB

Issue reported by Benjamin Dobell, see #48. The call to
WinUsb_QueryInterfaceSettings() is removed since it doesn't work
on any other interface but the first (a WinUSB limitation).

This allows the use of WinUSB.sys in lieu of the usbccgp.sys
"USB Generic Parent" default driver for composite devices.

Note: See TracTickets for help on using tickets.