linux/drivers/target
Bart Van Assche 3e45c8554b scsi: target/iscsi: Avoid iscsit_release_commands_from_conn() deadlock
commit 32e36bfbcf upstream.

When using SCSI passthrough in combination with the iSCSI target driver
then cmd->t_state_lock may be obtained from interrupt context. Hence, all
code that obtains cmd->t_state_lock from thread context must disable
interrupts first. This patch avoids that lockdep reports the following:

WARNING: inconsistent lock state
4.18.0-dbg+ #1 Not tainted
--------------------------------
inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
iscsi_ttx/1800 [HC1[1]:SC0[2]:HE0:SE0] takes:
000000006e7b0ceb (&(&cmd->t_state_lock)->rlock){?...}, at: target_complete_cmd+0x47/0x2c0 [target_core_mod]
{HARDIRQ-ON-W} state was registered at:
 lock_acquire+0xd2/0x260
 _raw_spin_lock+0x32/0x50
 iscsit_close_connection+0x97e/0x1020 [iscsi_target_mod]
 iscsit_take_action_for_connection_exit+0x108/0x200 [iscsi_target_mod]
 iscsi_target_rx_thread+0x180/0x190 [iscsi_target_mod]
 kthread+0x1cf/0x1f0
 ret_from_fork+0x24/0x30
irq event stamp: 1281
hardirqs last  enabled at (1279): [<ffffffff970ade79>] __local_bh_enable_ip+0xa9/0x160
hardirqs last disabled at (1281): [<ffffffff97a008a5>] interrupt_entry+0xb5/0xd0
softirqs last  enabled at (1278): [<ffffffff977cd9a1>] lock_sock_nested+0x51/0xc0
softirqs last disabled at (1280): [<ffffffffc07a6e04>] ip6_finish_output2+0x124/0xe40 [ipv6]

other info that might help us debug this:
Possible unsafe locking scenario:

      CPU0
      ----
 lock(&(&cmd->t_state_lock)->rlock);
 <Interrupt>
   lock(&(&cmd->t_state_lock)->rlock);
History 2019-07-09 22:03:54 +01:00
..
iscsi scsi: target/iscsi: Avoid iscsit_release_commands_from_conn() deadlock 2019-07-09 22:03:54 +01:00
loopback tcm_loop: Fixup tag handling 2015-01-22 16:33:35 +00:00
sbp target: Pass in transport supported PI at session initialization 2014-04-07 01:48:54 -07:00
tcm_fc tcm_fc: missing curly braces in ft_invl_hw_context() 2015-03-30 11:11:42 +01:00
Kconfig target/iblock: Add blk_integrity + BIP passthrough support 2014-01-18 10:14:22 +00:00
Makefile target: Add support for EXTENDED_COPY copy offload emulation 2013-09-10 16:48:43 -07:00
target_core_alua.c Merge branch 'next' (accumulated 3.16 merge window patches) into master 2014-06-08 11:31:16 -07:00
target_core_alua.h target_core_alua: Referrals configfs integration 2014-01-09 21:48:35 -08:00
target_core_configfs.c target: Fix a memory leak in target_dev_lba_map_store() 2016-02-02 19:48:58 +00:00
target_core_device.c target: Fix max_unmap_lba_count calc overflow 2016-11-20 01:16:55 +00:00
target_core_fabric_configfs.c target: Fix sizeof in kmalloc for some default_groups arrays 2013-12-16 12:42:20 -08:00
target_core_fabric_lib.c target: Update copyright ownership/year information to 2013 2013-09-10 20:23:36 -07:00
target_core_file.c target/fileio: Fix zero-length READ and WRITE handling 2017-08-26 02:14:46 +01:00
target_core_file.h Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2014-01-31 15:31:23 -08:00
target_core_hba.c target: Update copyright ownership/year information to 2013 2013-09-10 20:23:36 -07:00
target_core_iblock.c target: Fix max_unmap_lba_count calc overflow 2016-11-20 01:16:55 +00:00
target_core_iblock.h target: kill struct se_subsystem_dev 2012-11-06 20:55:43 -08:00
target_core_internal.h target: Fix kref->refcount underflow in transport_cmd_finish_abort 2017-09-15 18:30:07 +01:00
target_core_pr.c scsi: target: Fix truncated PR-in ReadKeys response 2018-11-20 18:05:18 +00:00
target_core_pr.h target: Fix APTPL metadata handling for dynamic MappedLUNs 2014-11-05 11:43:05 +00:00
target_core_pscsi.c target/pscsi: Fix TYPE_TAPE + TYPE_MEDIMUM_CHANGER export 2017-07-18 18:40:08 +01:00
target_core_pscsi.h target/pscsi: Don't leak scsi_host if hba is VIRTUAL_HOST 2015-06-03 14:30:06 +01:00
target_core_rd.c target/rd: T10-Dif: RAM disk is allocating more space than required. 2014-04-07 01:48:53 -07:00
target_core_rd.h target/rd: Add support for protection SGL setup + release 2014-01-19 02:22:05 +00:00
target_core_sbc.c target: Fix VERIFY_16 handling in sbc_parse_cdb 2017-07-18 18:40:09 +01:00
target_core_spc.c target: REPORT LUNS should return LUN 0 even for dynamic ACLs 2015-08-31 14:14:07 +01:00
target_core_stat.c target: Convert se_device statistics to atomic_long_t 2013-11-13 18:34:55 -08:00
target_core_tmr.c target: Avoid early CMD_T_PRE_EXECUTE failures during ABORT_TASK 2018-02-13 18:42:18 +00:00
target_core_tpg.c target: Fix APTPL metadata handling for dynamic MappedLUNs 2014-11-05 11:43:05 +00:00
target_core_transport.c target: Avoid early CMD_T_PRE_EXECUTE failures during ABORT_TASK 2018-02-13 18:42:18 +00:00
target_core_ua.c arch: Mass conversion of smp_mb__*() 2014-04-18 14:20:48 +02:00
target_core_ua.h target core: rename (ex,im)plict -> (ex,im)plicit 2013-11-20 11:24:40 -08:00
target_core_xcopy.c target: Use correct SCSI status during EXTENDED_COPY exception 2017-03-16 02:27:11 +00:00
target_core_xcopy.h target: Add support for EXTENDED_COPY copy offload emulation 2013-09-10 16:48:43 -07:00