OpenCloudOS-Kernel/drivers/usb
Maxime Bizon a398d5eac6 usb-storage: fix deadlock when a scsi command timeouts more than once
With faulty usb-storage devices, read/write can timeout, in that case
the SCSI layer will abort and re-issue the command. USB storage has no
internal timeout, it relies on SCSI layer aborting commands via
.eh_abort_handler() for non those responsive devices.

After two consecutive timeouts of the same command, SCSI layer calls
.eh_device_reset_handler(), without calling .eh_abort_handler() first.

With usb-storage, this causes a deadlock:

  -> .eh_device_reset_handler
    -> device_reset
      -> mutex_lock(&(us->dev_mutex));

mutex already by usb_stor_control_thread(), which is waiting for
command completion:

  -> usb_stor_control_thread (mutex taken here)
    -> usb_stor_invoke_transport
      -> usb_stor_Bulk_transport
        -> usb_stor_bulk_srb
	  -> usb_stor_bulk_transfer_sglist
	    -> usb_sg_wait

Make sure we cancel any pending command in .eh_device_reset_handler()
to avoid this.

Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
Cc: linux-usb@vger.kernel.org
Cc: stable <stable@kernel.org>
Link: https://lore.kernel.org/all/ZEllnjMKT8ulZbJh@sakura/
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20230505114759.1189741-1-mbizon@freebox.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-13 18:53:03 +09:00
..
atm usb: move from strlcpy with unused retval to strscpy 2022-08-19 11:08:54 +02:00
c67x00 USB: c67x00: remove unnecessary check of res 2022-05-12 11:36:46 +02:00
cdns3 Merge 6.3-rc6 into usb-next 2023-04-10 08:56:59 +02:00
chipidea usb: chipidea: fix missing goto in `ci_hdrc_probe` 2023-04-20 11:16:42 +02:00
class USB: usbtmc: Fix direction for 0-length ioctl control messages 2023-05-13 17:25:49 +09:00
common Char/Misc drivers for 6.4-rc1 2023-04-27 12:07:50 -07:00
core Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
dwc2 usb: dwc2: platform: add support for utmi optional clock 2023-04-20 10:17:06 +02:00
dwc3 usb: dwc3: fix a test for error in dwc3_core_init() 2023-05-13 18:52:04 +09:00
early usb: early: xhci-dbc: Use memcpy_and_pad() 2023-01-31 10:40:54 +01:00
fotg210 USB: fotg210: fix memory leak with using debugfs_lookup() 2023-02-06 13:46:42 +01:00
gadget usb: gadget: u_ether: Fix host MAC address case 2023-05-13 18:46:59 +09:00
host USB: UHCI: adjust zhaoxin UHCI controllers OverCurrent bit value 2023-05-13 17:55:45 +09:00
image scsi: usb: uas: Declare two host templates and host template pointers const 2023-03-24 19:20:00 -04:00
isp1760 usb: isp1760: Fix out-of-bounds array access 2022-05-19 18:10:59 +02:00
misc USB: sisusbvga: Add endpoint checks 2023-04-20 11:43:22 +02:00
mon driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
mtu3 usb: mtu3: add optional clock xhci_ck and frmcnt_ck 2023-04-20 11:17:05 +02:00
musb usb: musb: ux500: Convert to platform remove callback returning void 2023-04-05 19:07:42 +02:00
phy usb: phy: twl6030: Convert to platform remove callback returning void 2023-03-23 17:35:27 +01:00
renesas_usbhs usb: renesas_usbhs: drop of_match_ptr for ID table 2023-03-16 12:15:23 +01:00
roles driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
serial Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
storage usb-storage: fix deadlock when a scsi command timeouts more than once 2023-05-13 18:53:03 +09:00
typec usb: typec: tps6598x: Fix fault at module removal 2023-05-13 18:51:09 +09:00
usbip Including fixes from bpf, netfilter and can. 2022-12-21 08:41:32 -08:00
Kconfig usb: move config USB_USS720 to usb's misc Kconfig 2023-03-29 10:34:08 +02:00
Makefile usb: host: u132-hcd: Delete driver 2023-03-21 14:06:11 +01:00
usb-skeleton.c usb: add usb_set_intfdata() documentation 2022-11-29 08:56:09 +01:00