android_kernel_sony_sdm845/drivers/usb
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Alan Stern 21851aa886 USB: core: Fix misleading driver bug report
[ Upstream commit ac854131d9844f79e2fdcef67a7707227538d78a ]

The syzbot fuzzer found a race between URB submission to endpoint 0
and device reset.  Namely, during the reset we call usb_ep0_reinit()
because the characteristics of ep0 may have changed (if the reset
follows a firmware update, for example).  While usb_ep0_reinit() is
running there is a brief period during which the pointers stored in
udev->ep_in[0] and udev->ep_out[0] are set to NULL, and if an URB is
submitted to ep0 during that period, usb_urb_ep_type_check() will
report it as a driver bug.  In the absence of those pointers, the
routine thinks that the endpoint doesn't exist.  The log message looks
like this:

------------[ cut here ]------------
usb 2-1: BOGUS urb xfer, pipe 2 != type 2
WARNING: CPU: 0 PID: 9241 at drivers/usb/core/urb.c:478
usb_submit_urb+0x1188/0x1460 drivers/usb/core/urb.c:478

Now, although submitting an URB while the device is being reset is a
questionable thing to do, it shouldn't count as a driver bug as severe
as submitting an URB for an endpoint that doesn't exist.  Indeed,
endpoint 0 always exists, even while the device is in its unconfigured
state.

To prevent these misleading driver bug reports, this patch updates
usb_disable_endpoint() to avoid clearing the ep_in[] and ep_out[]
pointers when the endpoint being disabled is ep0.  There's no danger
of leaving a stale pointer in place, because the usb_host_endpoint
structure being pointed to is stored permanently in udev->ep0; it
doesn't get deallocated until the entire usb_device structure does.

Reported-and-tested-by: syzbot+db339689b2101f6f6071@syzkaller.appspotmail.com
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.2005011558590.903-100000@netrider.rowland.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-05-27 16:41:49 +02:00
..
atm USB: atm: ueagle-atm: add missing endpoint check 2019-12-21 10:41:53 +01:00
c67x00
chipidea usb: chipidea: host: Disable port power only if previously enabled 2020-01-14 20:04:25 +01:00
class USB: cdc-acm: restore capability check order 2020-04-02 17:20:36 +02:00
common usb: common: Consider only available nodes for dr_mode 2019-04-03 06:24:19 +02:00
core USB: core: Fix misleading driver bug report 2020-05-27 16:41:49 +02:00
dwc2 usb: dwc2: Fix DMA cache alignment issues 2019-06-22 08:17:20 +02:00
dwc3 usb: dwc3: don't set gadget->is_otg flag 2020-04-13 10:32:59 +02:00
early treewide: remove redundant #include <linux/kconfig.h> 2016-10-11 15:06:33 -07:00
gadget usb: gadget: legacy: fix error return code in cdc_bind() 2020-05-20 08:15:42 +02:00
host usb: xhci: Fix NULL pointer dereference when enqueuing trbs from urb sg list 2020-05-20 08:15:41 +02:00
image USB: microtek: fix info-leak at probe 2019-10-17 13:42:38 -07:00
isp1760
misc USB: sisusbvga: Change port variable from signed to unsigned 2020-05-02 17:23:10 +02:00
mon usb: mon: Fix a deadlock in usbmon between mmap and read 2019-12-21 10:41:56 +01:00
musb usb: musb: fix crash with highmen PIO and usbmon 2020-04-02 17:20:37 +02:00
phy usb: gadget: fsl: fix link error against usb-gadget module 2020-01-29 10:24:22 +01:00
renesas_usbhs usb: renesas_usbhs: add suspend event support in gadget mode 2020-01-04 13:39:14 +01:00
serial USB: serial: garmin_gps: add sanity checking for data length 2020-05-20 08:15:27 +02:00
storage USB: uas: add quirk for LaCie 2Big Quadra 2020-05-20 08:15:27 +02:00
usbip usbip: Fix error path of vhci_recv_ret_submit() 2020-01-04 13:40:20 +01:00
wusbcore usb: wusbcore: security: cast sizeof to int for comparison 2018-10-03 17:01:45 -07:00
Kconfig usb: Move USB_UHCI_BIG_ENDIAN_* out of USB_SUPPORT 2018-02-22 15:43:51 +01:00
Makefile
README
usb-skeleton.c USB: usb-skeleton: fix NULL-deref on disconnect 2019-10-17 13:42:29 -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 ("hub_wq").

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.