Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libusb_get_bos_descriptor() fails to check for bcdUSB > 0x0200 before querying device for BOS descriptor #1492

Open
njk42 opened this issue May 3, 2024 · 3 comments
Labels
core Related to common codes

Comments

@njk42
Copy link

njk42 commented May 3, 2024

It is my (hopefully correct) understanding that only USB 2.0 LPM and later standards (bcdUSB > 0x0200) require devices to support BOS descriptor query. However, the libusb function libusb_get_bos_descriptor() does not contain logic to first check the bcdUSB value is high enough, and therefore still queries devices with bcdUSB <= 0x0200 for a BOS descriptor.

For older USB 1.0 or USB 2.0 (not LPM) devices, the descriptor type = 0x0f could be undefined and requesting it could cause abnormal device behavior and the library could return LIBUSB_ERROR_TIMEOUT or LIBUSB_ERROR_PIPE when it should be returning LIBUSB_ERROR_NOT_FOUND according to the doxygen comment.

Some background:

https://techcommunity.microsoft.com/t5/microsoft-usb-blog/usb-2-1-2-0-1-1-device-enumeration-changes-in-windows-8/ba-p/270775

https://microchip.my.site.com/s/article/Does-a-USB2-1-Specification-Exist

@mcuee mcuee added the core Related to common codes label May 5, 2024
@tormodvolden
Copy link
Contributor

Does the standard disallow devices with bcdUSB <= 0x0200 to have a BOS descriptor?

I am not sure if libusb should stand in the way if a user wants to request a BOS descriptor.

We should maybe make our use of libusb_get_bos_descriptor() in xusb and testlibusb conditional on bcdUSB.

@mcuee mcuee added the Examples Examples label May 21, 2024
@mcuee
Copy link
Member

mcuee commented May 21, 2024

We should maybe make our use of libusb_get_bos_descriptor() in xusb and testlibusb conditional on bcdUSB.

Good idea.

tormodvolden added a commit that referenced this issue May 26, 2024
The "Binary device Object Store" (BOS) descriptor was introduced with
bcdUSB revision 0x0201.

References #1492

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
@tormodvolden
Copy link
Contributor

tormodvolden commented May 26, 2024

It was already tested for in testlibusb. I added the same check in xusb.

The question remains whether we should map pipe error in libusb_get_bos_descriptor() to LIBUSB_ERROR_NOT_FOUND if bcdUSB < 0x0201.

@tormodvolden tormodvolden removed the Examples Examples label May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to common codes
Projects
None yet
Development

No branches or pull requests

3 participants