Commit a398d5e
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>1 parent 8018018 commit a398d5e
1 file changed
+21
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
| 409 | + | |
410 | 410 | | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | 411 | | |
416 | 412 | | |
417 | 413 | | |
418 | 414 | | |
419 | 415 | | |
420 | 416 | | |
421 | | - | |
422 | | - | |
| 417 | + | |
| 418 | + | |
423 | 419 | | |
424 | 420 | | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
425 | 428 | | |
426 | 429 | | |
427 | 430 | | |
| |||
444 | 447 | | |
445 | 448 | | |
446 | 449 | | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
447 | 458 | | |
448 | 459 | | |
449 | 460 | | |
| |||
455 | 466 | | |
456 | 467 | | |
457 | 468 | | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
458 | 472 | | |
459 | 473 | | |
460 | 474 | | |
| |||
0 commit comments