linux-stable/drivers/target
Hou Pu ed43ffea78 scsi: target: iscsi: Fix hang in iscsit_access_np() when getting tpg->np_login_sem
The iSCSI target login thread might get stuck with the following stack:

cat /proc/`pidof iscsi_np`/stack
[<0>] down_interruptible+0x42/0x50
[<0>] iscsit_access_np+0xe3/0x167
[<0>] iscsi_target_locate_portal+0x695/0x8ac
[<0>] __iscsi_target_login_thread+0x855/0xb82
[<0>] iscsi_target_login_thread+0x2f/0x5a
[<0>] kthread+0xfa/0x130
[<0>] ret_from_fork+0x1f/0x30

This can be reproduced via the following steps:

1. Initiator A tries to log in to iqn1-tpg1 on port 3260. After finishing
   PDU exchange in the login thread and before the negotiation is finished
   the the network link goes down. At this point A has not finished login
   and tpg->np_login_sem is held.

2. Initiator B tries to log in to iqn2-tpg1 on port 3260. After finishing
   PDU exchange in the login thread the target expects to process remaining
   login PDUs in workqueue context.

3. Initiator A' tries to log in to iqn1-tpg1 on port 3260 from a new
   socket. A' will wait for tpg->np_login_sem with np->np_login_timer
   loaded to wait for at most 15 seconds. The lock is held by A so A'
   eventually times out.

4. Before A' got timeout initiator B gets negotiation failed and calls
   iscsi_target_login_drop()->iscsi_target_login_sess_out().  The
   np->np_login_timer is canceled and initiator A' will hang forever.
   Because A' is now in the login thread, no new login requests can be
   serviced.

Fix this by moving iscsi_stop_login_thread_timer() out of
iscsi_target_login_sess_out(). Also remove iscsi_np parameter from
iscsi_target_login_sess_out().

Link: https://lore.kernel.org/r/20200729130343.24976-1-houpu@bytedance.com
Cc: stable@vger.kernel.org
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Hou Pu <houpu@bytedance.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2020-09-02 21:08:22 -04:00
..
iscsi scsi: target: iscsi: Fix hang in iscsit_access_np() when getting tpg->np_login_sem 2020-09-02 21:08:22 -04:00
loopback scsi: target: loopback: Fix READ with data and sensebytes 2020-05-11 22:20:19 -04:00
sbp
tcm_fc scsi: libfc: remove unnecessary assertion on ep variable 2019-12-19 22:08:55 -05:00
Kconfig
Makefile
target_core_alua.c scsi: target: Make transport_flags per device 2020-05-07 22:39:21 -04:00
target_core_alua.h
target_core_configfs.c scsi: target: tcmu: Make pgr_support and alua_support attributes writable 2020-05-07 22:39:22 -04:00
target_core_device.c scsi: target: Initialize LUN in transport_init_se_cmd() 2020-06-09 21:57:26 -04:00
target_core_fabric_configfs.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
target_core_fabric_lib.c scsi: target: Handle short iSIDs 2020-07-08 00:14:34 -04:00
target_core_file.c
target_core_file.h
target_core_hba.c
target_core_iblock.c scsi: target/iblock: fix WRITE SAME zeroing 2020-04-22 00:02:13 -04:00
target_core_iblock.h
target_core_internal.h scsi: target: Fix xcopy sess release leak 2020-07-08 00:14:34 -04:00
target_core_pr.c scsi: target: Remove unused variable 'tpg' 2020-07-13 23:11:15 -04:00
target_core_pr.h
target_core_pscsi.c scsi: target: Make transport_flags per device 2020-05-07 22:39:21 -04:00
target_core_pscsi.h
target_core_rd.c
target_core_rd.h
target_core_sbc.c
target_core_spc.c scsi: target: use an enum to track emulate_ua_intlck_ctrl 2020-02-21 17:37:16 -05:00
target_core_stat.c
target_core_tmr.c scsi: target: Add tmr_notify backend function 2020-07-28 22:25:26 -04:00
target_core_tpg.c scsi: target: Make transport_flags per device 2020-05-07 22:39:21 -04:00
target_core_transport.c scsi: target: Add tmr_notify backend function 2020-07-28 22:25:26 -04:00
target_core_ua.c scsi: target: use an enum to track emulate_ua_intlck_ctrl 2020-02-21 17:37:16 -05:00
target_core_ua.h
target_core_user.c scsi: target: tcmu: Make TMR notification optional 2020-07-28 22:25:31 -04:00
target_core_xcopy.c scsi: target: Fix xcopy sess release leak 2020-07-08 00:14:34 -04:00
target_core_xcopy.h scsi: target: use the stack for XCOPY passthrough cmds 2020-03-29 18:10:59 -04:00