1
0
Fork 0
alistair23-linux/drivers/usb
Alan Stern c8d323578e USB: core: Fix misleading driver bug report
[ Upstream commit ac854131d9 ]

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 17:46:34 +02:00
..
atm USB: atm: ueagle-atm: add missing endpoint check 2019-12-17 19:55:44 +01:00
c67x00 USB: add SPDX identifiers to all remaining Makefiles 2017-11-07 15:53:48 +01:00
cdns3 usb: cdns3: gadget: prev_req->trb is NULL for ep0 2020-05-20 08:20:31 +02:00
chipidea usb: chipidea: msm: Ensure proper controller reset using role switch API 2020-05-14 07:58:25 +02:00
class cdc-acm: introduce a cool down 2020-04-29 16:33:22 +02:00
common usb: common: usb-conn-gpio: Don't log an error on probe deferral 2019-12-17 19:55:39 +01:00
core USB: core: Fix misleading driver bug report 2020-05-27 17:46:34 +02:00
dwc2 usb: dwc2: Fix in ISOC request length checking 2020-02-28 17:22:26 +01:00
dwc3 dwc3: Remove check for HWO flag in dwc3_gadget_ep_reclaim_trb_sg() 2020-05-20 08:20:35 +02:00
early USB: early: Handle AMD's spec-compliant identifiers, too 2020-04-29 16:33:13 +02:00
gadget usb: gadget: legacy: fix error return code in cdc_bind() 2020-05-20 08:20:36 +02:00
host usb: xhci: Fix NULL pointer dereference when enqueuing trbs from urb sg list 2020-05-20 08:20:32 +02:00
image USB: microtek: fix info-leak at probe 2019-10-04 11:02:58 +02:00
isp1760 usb: add a HCD_DMA flag instead of guestimating DMA capabilities 2019-08-21 10:03:35 -07:00
misc USB: sisusbvga: Change port variable from signed to unsigned 2020-04-29 16:33:13 +02:00
mon usb: mon: Fix a deadlock in usbmon between mmap and read 2019-12-17 19:55:49 +01:00
mtu3 usb: mtu3: fix missing include of mtu3_dr.h 2019-10-27 08:58:44 +02:00
musb usb: musb: fix crash with highmen PIO and usbmon 2020-04-01 11:02:15 +02:00
phy USB: Changes for v5.4 merge window 2019-09-02 19:20:57 +02:00
renesas_usbhs usb: renesas_usbhs: add suspend event support in gadget mode 2019-12-31 16:43:37 +01:00
roles usb: roles: fix a potential use after free 2019-12-17 19:55:46 +01:00
serial USB: serial: garmin_gps: add sanity checking for data length 2020-05-14 07:58:25 +02:00
storage USB: uas: add quirk for LaCie 2Big Quadra 2020-05-14 07:58:25 +02:00
typec usb: typec: altmode: Fix typec_altmode_get_partner sometimes returning an invalid pointer 2020-04-29 16:33:23 +02:00
usbip usbip: Fix error path of vhci_recv_ret_submit() 2019-12-31 16:46:05 +01:00
Kconfig usb: common: create Kconfig file 2019-09-03 19:00:39 +02:00
Makefile USB: Changes for v5.4 merge window 2019-09-02 19:20:57 +02:00
usb-skeleton.c USB: usb-skeleton: drop redundant in-urb check 2019-10-10 12:41:19 +02:00