• Bart Van Assche's avatar
    scsi: target/iscsi: Avoid iscsit_release_commands_from_conn() deadlock · 8ec3bcb5
    Bart Van Assche authored
    commit 32e36bfbcf31452a854263e7c7f32fbefc4b44d8 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);
    8ec3bcb5
Name
Last commit
Last update
..
iscsi Loading commit data...
loopback Loading commit data...
sbp Loading commit data...
tcm_fc Loading commit data...
Kconfig Loading commit data...
Makefile Loading commit data...
target_core_alua.c Loading commit data...
target_core_alua.h Loading commit data...
target_core_configfs.c Loading commit data...
target_core_device.c Loading commit data...
target_core_fabric_configfs.c Loading commit data...
target_core_fabric_lib.c Loading commit data...
target_core_file.c Loading commit data...
target_core_file.h Loading commit data...
target_core_hba.c Loading commit data...
target_core_iblock.c Loading commit data...
target_core_iblock.h Loading commit data...
target_core_internal.h Loading commit data...
target_core_pr.c Loading commit data...
target_core_pr.h Loading commit data...
target_core_pscsi.c Loading commit data...
target_core_pscsi.h Loading commit data...
target_core_rd.c Loading commit data...
target_core_rd.h Loading commit data...
target_core_sbc.c Loading commit data...
target_core_spc.c Loading commit data...
target_core_stat.c Loading commit data...
target_core_tmr.c Loading commit data...
target_core_tpg.c Loading commit data...
target_core_transport.c Loading commit data...
target_core_ua.c Loading commit data...
target_core_ua.h Loading commit data...
target_core_user.c Loading commit data...
target_core_xcopy.c Loading commit data...
target_core_xcopy.h Loading commit data...