New issue
Advanced search Search tips

Issue 679314 link

Starred by 4 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 3
Type: Bug



Sign in to add a comment

Kernel driver is not detached before claiming device

Reported by k...@karelbilek.com, Jan 9 2017

Issue description

Chrome Version       : 55.0.2883.87 (Official Build) unknown (64-bit) (Linux)

(Also tested on Mac.)

What steps will reproduce the problem?

(1) Connect a device, that has set up HID device class on an interface, but is not actually keyboard/mouse
(2) Ask chrome to open the device and claim the interface via claimInterface

What is the expected result?

The interface is claimed.

What happens instead?

The interface is not claimed.

Please provide any additional information below. Attach a screenshot if
possible.

The interface is not claimed, because kernel still has the device attached.

The interface is claimed here

https://chromium.googlesource.com/chromium/src/+/master/device/usb/usb_device_handle_impl.cc#843

The documentation to the call is here

http://libusb.sourceforge.net/api-1.0/group__dev.html#ga32fabedf5f13fdecf1cb33acdb19b57a

So there seem to be three different solutions:

(1) detach the kernel driver by hand with libusb_detach_kernel_driver and attach it again after releasing the interface
(2) set libusb_set_auto_detach_kernel_driver to true
(3) add another JS function to USBDevice class `Promise<void> detachKernelDriver()`

When I now experimented with libusb on my HID device, it seems like it is indeed enough to call libusb_set_auto_detach_kernel_driver; and it works for non-root users. 

So it could probably be fixed by one-line changes in `UsbDeviceHandleImpl::ClaimInterfaceOnBlockingThread` and `UsbDeviceHandleImpl::InterfaceClaimer::~InterfaceClaimer`; but I cannot test that now (don't have 100GB free space to build Chromium :D).

The other question is if it's a bug or a feature :)

In the webusb draft, in ยง1 Introduction, I see that it's mainly intended for devices without a driver; however, I don't see anything that would specifically *forbid* webusb to work with HID devices.

One of the concrete examples is U2F devices like yubico, that work through HID. And Google Chrome actually talks to them via chrome.hid via built-in extension 

https://chromium.googlesource.com/chromium/src/+/master/chrome/browser/resources/cryptotoken/hidgnubbydevice.js#512

(even when other extensions cannot use chrome.hid, because those permissions are available only for Chrome Apps, that Google is sunsetting)

Slightly related bug:

https://bugs.chromium.org/p/chromium/issues/detail?id=678885

Somehow related discussion:

https://github.com/WICG/webusb/issues/29
 

Comment 1 Deleted

The error is not related only for HID devices, but any device that kernel has attached driver to, but I hit it with a HID device :)
Labels: TE-Hardware-Dependency
Labels: OS-Android OS-Chrome OS-Linux OS-Mac OS-Windows
WebUSB doesn't use libusb_detach_kernel_driver because detaching kernel drivers is not supported universally on all platforms Chrome runs on. It should work for most Linux kernel drivers but is an optional feature for macOS kernel drivers and requires elevated privileges and heavy-handed reconfiguration using the PnP configuration API on Windows that is not easily undone. We do not want to leave a device in an unusable configuration at the request of arbitrary web pages.
Status: WontFix (was: Unconfirmed)

Sign in to add a comment