lkml.org 
[lkml]   [2019]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.19 161/280] scsi: target/iscsi: Avoid iscsit_release_commands_from_conn() deadlock
    Date
    4.19-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Bart Van Assche <bvanassche@acm.org>

    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);

    ---
    drivers/target/iscsi/iscsi_target.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    --- a/drivers/target/iscsi/iscsi_target.c
    +++ b/drivers/target/iscsi/iscsi_target.c
    @@ -4045,9 +4045,9 @@ static void iscsit_release_commands_from
    struct se_cmd *se_cmd = &cmd->se_cmd;

    if (se_cmd->se_tfo != NULL) {
    - spin_lock(&se_cmd->t_state_lock);
    + spin_lock_irq(&se_cmd->t_state_lock);
    se_cmd->transport_state |= CMD_T_FABRIC_STOP;
    - spin_unlock(&se_cmd->t_state_lock);
    + spin_unlock_irq(&se_cmd->t_state_lock);
    }
    }
    spin_unlock_bh(&conn->cmd_lock);

    \
     
     \ /
      Last update: 2019-03-22 13:43    [W:4.215 / U:0.160 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site