linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Alan Stern <stern@rowland.harvard.edu>,
	Sasha Levin <sashal@kernel.org>,
	syzbot+db339689b2101f6f6071@syzkaller.appspotmail.com
Subject: [PATCH 4.19 32/81] USB: core: Fix misleading driver bug report
Date: Tue, 26 May 2020 20:53:07 +0200	[thread overview]
Message-ID: <20200526183930.993182715@linuxfoundation.org> (raw)
In-Reply-To: <20200526183923.108515292@linuxfoundation.org>

From: Alan Stern <stern@rowland.harvard.edu>

[ 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>
---
 drivers/usb/core/message.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index fcf84bfc08e3..f705ea52eb97 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1143,11 +1143,11 @@ void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr,
 
 	if (usb_endpoint_out(epaddr)) {
 		ep = dev->ep_out[epnum];
-		if (reset_hardware)
+		if (reset_hardware && epnum != 0)
 			dev->ep_out[epnum] = NULL;
 	} else {
 		ep = dev->ep_in[epnum];
-		if (reset_hardware)
+		if (reset_hardware && epnum != 0)
 			dev->ep_in[epnum] = NULL;
 	}
 	if (ep) {
-- 
2.25.1




  parent reply	other threads:[~2020-05-26 19:03 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26 18:52 [PATCH 4.19 00/81] 4.19.125-rc1 review Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 01/81] x86/uaccess, ubsan: Fix UBSAN vs. SMAP Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 02/81] ubsan: build ubsan.c more conservatively Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 03/81] i2c: dev: Fix the race between the release of i2c_dev and cdev Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 04/81] KVM: SVM: Fix potential memory leak in svm_cpu_init() Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 05/81] riscv: set max_pfn to the PFN of the last page Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 06/81] ima: Set file->f_mode instead of file->f_flags in ima_calc_file_hash() Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 07/81] evm: Check also if *tfm is an error pointer in init_desc() Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 08/81] ima: Fix return value of ima_write_policy() Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 09/81] mtd: spinand: Propagate ECC information to the MTD structure Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 10/81] fix multiplication overflow in copy_fdtable() Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 11/81] ubifs: remove broken lazytime support Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 12/81] iommu/amd: Fix over-read of ACPI UID from IVRS table Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 13/81] i2c: mux: demux-pinctrl: Fix an error handling path in i2c_demux_pinctrl_probe() Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 14/81] ubi: Fix seq_file usage in detailed_erase_block_info debugfs file Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 15/81] gcc-common.h: Update for GCC 10 Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 16/81] HID: multitouch: add eGalaxTouch P80H84 support Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 17/81] HID: alps: Add AUI1657 device ID Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 18/81] HID: alps: ALPS_1657 is too specific; use U1_UNICORN_LEGACY instead Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 19/81] scsi: qla2xxx: Fix hang when issuing nvme disconnect-all in NPIV Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 20/81] scsi: qla2xxx: Delete all sessions before unregister local nvme port Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 21/81] configfs: fix config_item refcnt leak in configfs_rmdir() Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 22/81] vhost/vsock: fix packet delivery order to monitoring devices Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 23/81] aquantia: Fix the media type of AQC100 ethernet controller in the driver Greg Kroah-Hartman
2020-05-26 18:52 ` [PATCH 4.19 24/81] component: Silence bind error on -EPROBE_DEFER Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 25/81] scsi: ibmvscsi: Fix WARN_ON during event pool release Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 26/81] HID: i2c-hid: reset Synaptics SYNA2393 on resume Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 27/81] x86/apic: Move TSC deadline timer debug printk Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 28/81] gtp: set NLM_F_MULTI flag in gtp_genl_dump_pdp() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 29/81] HID: quirks: Add HID_QUIRK_NO_INIT_REPORTS quirk for Dell K12A keyboard-dock Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 30/81] ceph: fix double unlock in handle_cap_export() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 31/81] stmmac: fix pointer check after utilization in stmmac_interrupt Greg Kroah-Hartman
2020-05-26 18:53 ` Greg Kroah-Hartman [this message]
2020-05-26 18:53 ` [PATCH 4.19 33/81] platform/x86: asus-nb-wmi: Do not load on Asus T100TA and T200TA Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 34/81] ARM: futex: Address build warning Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 35/81] padata: Replace delayed timer with immediate workqueue in padata_reorder Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 36/81] padata: initialize pd->cpu with effective cpumask Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 37/81] padata: purge get_cpu and reorder_via_wq from padata_do_serial Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 38/81] ALSA: iec1712: Initialize STDSP24 properly when using the model=staudio option Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 39/81] ALSA: pcm: fix incorrect hw_base increase Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 40/81] ALSA: hda/realtek - Fix silent output on Gigabyte X570 Aorus Xtreme Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 41/81] ALSA: hda/realtek - Add more fixup entries for Clevo machines Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 42/81] drm/etnaviv: fix perfmon domain interation Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 43/81] apparmor: Fix use-after-free in aa_audit_rule_init Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 44/81] apparmor: fix potential label refcnt leak in aa_change_profile Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 45/81] apparmor: Fix aa_label refcnt leak in policy_update Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 46/81] dmaengine: tegra210-adma: Fix an error handling path in tegra_adma_probe() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 47/81] dmaengine: owl: Use correct lock in owl_dma_get_pchan() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 48/81] drm/i915/gvt: Init DPLL/DDI vreg for virtual display instead of inheritance Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 49/81] powerpc: Remove STRICT_KERNEL_RWX incompatibility with RELOCATABLE Greg Kroah-Hartman
2020-05-27 13:28   ` Pavel Machek
2020-05-27 14:32     ` Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 50/81] powerpc/64s: Disable STRICT_KERNEL_RWX Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 51/81] nfit: Add Hyper-V NVDIMM DSM command set to white list Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 52/81] libnvdimm/btt: Remove unnecessary code in btt_freelist_init Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 53/81] libnvdimm/btt: Fix LBA masking during free list population Greg Kroah-Hartman
2020-05-27 13:33   ` Pavel Machek
2020-05-26 18:53 ` [PATCH 4.19 54/81] staging: most: core: replace strcpy() by strscpy() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 55/81] thunderbolt: Drop duplicated get_switch_at_route() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 56/81] media: fdp1: Fix R-Car M3-N naming in debug message Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 57/81] Revert "net/ibmvnic: Fix EOI when running in XIVE mode" Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 58/81] net: bcmgenet: code movement Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 59/81] net: bcmgenet: abort suspend on error Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 60/81] cxgb4: free mac_hlist properly Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 61/81] cxgb4/cxgb4vf: Fix mac_hlist initialization and free Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 62/81] tty: serial: qcom_geni_serial: Fix wrap around of TX buffer Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 63/81] brcmfmac: abort and release host after error Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 64/81] Revert "gfs2: Dont demote a glock until its revokes are written" Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 65/81] staging: iio: ad2s1210: Fix SPI reading Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 66/81] staging: greybus: Fix uninitialized scalar variable Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 67/81] iio: sca3000: Remove an erroneous get_device() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 68/81] iio: dac: vf610: Fix an error handling path in vf610_dac_probe() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 69/81] misc: rtsx: Add short delay after exit from ASPM Greg Kroah-Hartman
2020-05-29 16:26   ` Pavel Machek
2020-05-26 18:53 ` [PATCH 4.19 70/81] mei: release me_cl object reference Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 71/81] ipack: tpci200: fix error return code in tpci200_register() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 72/81] rapidio: fix an error in get_user_pages_fast() error handling Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 73/81] rxrpc: Fix a memory leak in rxkad_verify_response() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 74/81] x86/unwind/orc: Fix unwind_get_return_address_ptr() for inactive tasks Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 75/81] iio: adc: stm32-adc: Use dma_request_chan() instead dma_request_slave_channel() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 76/81] iio: adc: stm32-adc: fix device used to request dma Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 77/81] iio: adc: stm32-dfsdm: Use dma_request_chan() instead dma_request_slave_channel() Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 78/81] iio: adc: stm32-dfsdm: fix device used to request dma Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 79/81] rxrpc: Trace discarded ACKs Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 80/81] rxrpc: Fix ack discard Greg Kroah-Hartman
2020-05-26 18:53 ` [PATCH 4.19 81/81] make user_access_begin() do access_ok() Greg Kroah-Hartman
2020-05-27  8:30 ` [PATCH 4.19 00/81] 4.19.125-rc1 review Naresh Kamboju
2020-05-27  8:33 ` Jon Hunter
2020-05-27 10:29 ` Chris Paterson
2020-05-27 11:48   ` Greg Kroah-Hartman
2020-05-27 14:02 ` Guenter Roeck
2020-05-27 15:28   ` Greg Kroah-Hartman
2020-05-27 16:38 ` shuah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200526183930.993182715@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=syzbot+db339689b2101f6f6071@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).