linux/drivers/usb
Kurt Garloff 831abf7664 usb/core/devio.c: Don't reject control message to endpoint with wrong direction bit
Trying to read data from the Pegasus Technologies NoteTaker (0e20:0101)
[1] with the Windows App (EasyNote) works natively but fails when
Windows is running under KVM (and the USB device handed to KVM).

The reason is a USB control message
 usb 4-2.2: control urb: bRequestType=22 bRequest=09 wValue=0200 wIndex=0001 wLength=0008
This goes to endpoint address 0x01 (wIndex); however, endpoint address
0x01 does not exist. There is an endpoint 0x81 though (same number,
but other direction); the app may have meant that endpoint instead.

The kernel thus rejects the IO and thus we see the failure.

Apparently, Linux is more strict here than Windows ... we can't change
the Win app easily, so that's a problem.

It seems that the Win app/driver is buggy here and the driver does not
behave fully according to the USB HID class spec that it claims to
belong to.  The device seems to happily deal with that though (and
seems to not really care about this value much).

So the question is whether the Linux kernel should filter here.
Rejecting has the risk that somewhat non-compliant userspace apps/
drivers (most likely in a virtual machine) are prevented from working.
Not rejecting has the risk of confusing an overly sensitive device with
such a transfer. Given the fact that Windows does not filter it makes
this risk rather small though.

The patch makes the kernel more tolerant: If the endpoint address in
wIndex does not exist, but an endpoint with toggled direction bit does,
it will let the transfer through. (It does NOT change the message.)

With attached patch, the app in Windows in KVM works.
 usb 4-2.2: check_ctrlrecip: process 13073 (qemu-kvm) requesting ep 01 but needs 81

I suspect this will mostly affect apps in virtual environments; as on
Linux the apps would have been adapted to the stricter handling of the
kernel. I have done that for mine[2].

[1] http://www.pegatech.com/
[2] https://sourceforge.net/projects/notetakerpen/

Signed-off-by: Kurt Garloff <kurt@garloff.de>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-25 17:30:39 -07:00
..
atm usb: atm: speedtch: be careful with bInterval 2013-07-25 11:49:30 -07:00
c67x00 USB: c67x00: use dev_get_platdata() 2013-07-31 17:28:44 -07:00
chipidea usb: chipidea: USB_CHIPIDEA should depend on HAS_DMA 2013-09-25 17:30:39 -07:00
class USB: usbtmc: fix up attribute permissions 2013-08-25 15:12:03 -07:00
core usb/core/devio.c: Don't reject control message to endpoint with wrong direction bit 2013-09-25 17:30:39 -07:00
dwc3 usb: dwc3: gadget: avoid memory leak when failing to allocate all eps 2013-09-17 11:05:01 -05:00
early
gadget usb: fixes for v3.12-rc2 2013-09-17 13:00:43 -07:00
host USB: fix PM config symbol in uhci-hcd, ehci-hcd, and xhci-hcd 2013-09-25 17:05:35 -07:00
image USB: regroup all depends on USB within an if USB block 2013-04-09 16:49:07 -07:00
misc Merge 3.11-rc6 into usb-next 2013-08-18 20:33:01 -07:00
mon USB: regroup all depends on USB within an if USB block 2013-04-09 16:49:07 -07:00
musb Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
phy usb: phy: omap-usb3: Fix return value 2013-09-17 11:05:30 -05:00
renesas_usbhs Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
serial USB: pl2303: distinguish between original and cloned HX chips 2013-09-17 09:36:10 -07:00
storage USB storage: audit sysfs attribute permissions 2013-08-27 13:13:07 -07:00
wusbcore Merge 3.11-rc6 into usb-next 2013-08-18 20:33:01 -07:00
Kconfig usb: Move definition of USB_EHCI_BIG_ENDIAN_MMIO et al. out side of the ifs. 2013-08-12 12:18:38 -07:00
Makefile usb: patches for v3.12 merge window 2013-08-13 15:28:01 -07:00
README
usb-common.c usb: common: introduce of_usb_get_maximum_speed() 2013-07-29 13:56:46 +03:00
usb-skeleton.c USB: usb-skeleton.c: add retry for nonblocking read 2013-07-25 12:01:13 -07:00

To understand all the Linux-USB framework, you'll use these resources:

    * This source code.  This is necessarily an evolving work, and
      includes kerneldoc that should help you get a current overview.
      ("make pdfdocs", and then look at "usb.pdf" for host side and
      "gadget.pdf" for peripheral side.)  Also, Documentation/usb has
      more information.

    * The USB 2.0 specification (from www.usb.org), with supplements
      such as those for USB OTG and the various device classes.
      The USB specification has a good overview chapter, and USB
      peripherals conform to the widely known "Chapter 9".

    * Chip specifications for USB controllers.  Examples include
      host controllers (on PCs, servers, and more); peripheral
      controllers (in devices with Linux firmware, like printers or
      cell phones); and hard-wired peripherals like Ethernet adapters.

    * Specifications for other protocols implemented by USB peripheral
      functions.  Some are vendor-specific; others are vendor-neutral
      but just standardized outside of the www.usb.org team.

Here is a list of what each subdirectory here is, and what is contained in
them.

core/		- This is for the core USB host code, including the
		  usbfs files and the hub class driver ("khubd").

host/		- This is for USB host controller drivers.  This
		  includes UHCI, OHCI, EHCI, and others that might
		  be used with more specialized "embedded" systems.

gadget/		- This is for USB peripheral controller drivers and
		  the various gadget drivers which talk to them.


Individual USB driver directories.  A new driver should be added to the
first subdirectory in the list below that it fits into.

image/		- This is for still image drivers, like scanners or
		  digital cameras.
../input/	- This is for any driver that uses the input subsystem,
		  like keyboard, mice, touchscreens, tablets, etc.
../media/	- This is for multimedia drivers, like video cameras,
		  radios, and any other drivers that talk to the v4l
		  subsystem.
../net/		- This is for network drivers.
serial/		- This is for USB to serial drivers.
storage/	- This is for USB mass-storage drivers.
class/		- This is for all USB device drivers that do not fit
		  into any of the above categories, and work for a range
		  of USB Class specified devices. 
misc/		- This is for all USB device drivers that do not fit
		  into any of the above categories.