linux-stable/drivers/usb/storage
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
..
alauda.c usb: storage: Add check for kcalloc 2022-12-08 16:43:12 +01:00
cypress_atacb.c
datafab.c
debug.c
debug.h
ene_ub6250.c USB: ene_usb6250: Allocate enough memory for full object 2023-02-06 13:46:42 +01:00
freecom.c
initializers.c
initializers.h
isd200.c
jumpshot.c
karma.c
Kconfig
Makefile
onetouch.c
option_ms.c
option_ms.h
protocol.c
protocol.h
realtek_cr.c
scsiglue.c usb-storage: fix deadlock when a scsi command timeouts more than once 2023-05-13 18:53:03 +09:00
scsiglue.h
sddr09.c
sddr55.c
shuttle_usbat.c
sierra_ms.c
sierra_ms.h
transport.c
transport.h
uas-detect.h usb-storage: apply IGNORE_UAS only for HIKSEMI MD202 on RTL9210 2023-01-17 16:37:04 +01:00
uas.c scsi: usb: uas: Declare two host templates and host template pointers const 2023-03-24 19:20:00 -04:00
unusual_alauda.h
unusual_cypress.h
unusual_datafab.h
unusual_devs.h
unusual_ene_ub6250.h
unusual_freecom.h
unusual_isd200.h
unusual_jumpshot.h
unusual_karma.h
unusual_onetouch.h
unusual_realtek.h
unusual_sddr09.h
unusual_sddr55.h
unusual_uas.h uas: Add US_FL_NO_REPORT_OPCODES for JMicron JMS583Gen 2 2023-03-16 12:44:17 +01:00
unusual_usbat.h
usb.c scsi: usb: uas: Declare two host templates and host template pointers const 2023-03-24 19:20:00 -04:00
usb.h scsi: usb: uas: Declare two host templates and host template pointers const 2023-03-24 19:20:00 -04:00
usual-tables.c