linux-stable/drivers/scsi/qedi
Mike Christie f10f582d28 scsi: qedi: Fix ABBA deadlock in qedi_process_tmf_resp() and qedi_process_cmd_cleanup_resp()
This fixes a deadlock added with commit b40f3894e3 ("scsi: qedi: Complete
TMF works before disconnect")

Bug description from Jia-Ju Bai:

qedi_process_tmf_resp()
  spin_lock(&session->back_lock); --> Line 201 (Lock A)
  spin_lock(&qedi_conn->tmf_work_lock); --> Line 230 (Lock B)

qedi_process_cmd_cleanup_resp()
  spin_lock_bh(&qedi_conn->tmf_work_lock); --> Line 752 (Lock B)
  spin_lock_bh(&conn->session->back_lock); --> Line 784 (Lock A)

When qedi_process_tmf_resp() and qedi_process_cmd_cleanup_resp() are
concurrently executed, the deadlock can occur.

This patch fixes the deadlock by not holding the tmf_work_lock in
qedi_process_cmd_cleanup_resp while holding the back_lock. The
tmf_work_lock is only needed while we remove the tmf_work from the
work_list.

Link: https://lore.kernel.org/r/20220208185448.6206-1-michael.christie@oracle.com
Fixes: b40f3894e3 ("scsi: qedi: Complete TMF works before disconnect")
Cc: Manish Rangankar <mrangankar@marvell.com>
Cc: Nilesh Javali <njavali@marvell.com>
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Reported-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2022-02-11 16:40:04 -05:00
..
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
Makefile
qedi.h scsi: qedi: Fix cleanup session block/unblock use 2021-06-02 01:28:23 -04:00
qedi_dbg.c
qedi_dbg.h scsi: Fix various misspellings of "connect" 2019-10-24 21:22:32 -04:00
qedi_debugfs.c qed: Remove e4_ and _e4 from FW HSI 2021-10-04 12:55:48 +01:00
qedi_fw.c scsi: qedi: Fix ABBA deadlock in qedi_process_tmf_resp() and qedi_process_cmd_cleanup_resp() 2022-02-11 16:40:04 -05:00
qedi_fw_api.c qed: Remove e4_ and _e4 from FW HSI 2021-10-04 12:55:48 +01:00
qedi_fw_iscsi.h qed: Remove e4_ and _e4 from FW HSI 2021-10-04 12:55:48 +01:00
qedi_fw_scsi.h
qedi_gbl.h scsi: qedi: Switch to attribute groups 2021-10-16 21:45:58 -04:00
qedi_hsi.h
qedi_iscsi.c scsi: qedi: Fix cmd_cleanup_cmpl counter mismatch issue 2021-12-06 22:00:54 -05:00
qedi_iscsi.h scsi: qedi: Fix cmd_cleanup_cmpl counter mismatch issue 2021-12-06 22:00:54 -05:00
qedi_main.c scsi: qedi: Fix SYSFS_FLAG_FW_SEL_BOOT formatting 2021-12-06 22:17:18 -05:00
qedi_nvm_iscsi_cfg.h
qedi_sysfs.c scsi: qedi: Switch to attribute groups 2021-10-16 21:45:58 -04:00
qedi_version.h