Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp671437img; Fri, 22 Mar 2019 06:18:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPlb16xxQ0xkh5+h+rt8Ts4K9htuZuOWVRWxPr2e03R+37ltEZz8KS3XeUqRfD9zponQSw X-Received: by 2002:a62:ab13:: with SMTP id p19mr9016913pff.131.1553260690630; Fri, 22 Mar 2019 06:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553260690; cv=none; d=google.com; s=arc-20160816; b=Em3Q0Lg5JznqPZuTrIgEOtDciVcqibYUj5lIppJFXynhGdD/YjvnrmPtI32X6Iu8gk FzS852JzLwGXQVfqLSqmiD2TP1Jkfm3O2SNGjCiKDH32vhTVa2Lfh+HVO7cekao1N3kO MBu2BrnT+L6h2c4mvSG08nl3mhcdGWrIBhk5KJM/lfnuW2rf5Ks/KdSmWGy8U6G4ElCn q+Wx+GrjYuRdGCLA4ljL9Cd6QGbnSXj6LklXULMG/PYB+EY549iM0lWWQOMGC2QFBYG6 97OuXgtPbcgCMnTKBv43dcl4pFtgEzjwVOWpXYAP/PaMmPbSwkAf+HQlitb8//hjlSTE i2lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vZVdtLIIOveWhK5kA4fx9XH9XagO33Gm40viXUnuKjY=; b=FH7WFDqJN+KarVPDbwTK3UQVrsCZH60m/kt6DSKEe5W56/jDy/LU5tXxMXxkjpZgkx GlsC/YnxhhoBlLaRktGjAqEn7tyuP367NV90AcB8aPLW2F6b2TndVvED3f8X3L9AzHEF jBgqH/S7QuqYp5tH2Osr3kmdKervlVXplBz8IPmyLhlp82V0alIpENTu+c4QHnRYg6oN KUJ3MlIYT8heGDSf++YxBR5ckvDZgc1bWjQB7h/tVyAL6wjXu7bQKtM5tRfa2o4zPnu0 FTZL6f+g6njDkKd1GxIagvodpJir4SHQ+kXLFfB29qfkl7ldPR5XeYFIvzdyItBwq4VK TmdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oVWfdfkR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12si5136218plt.69.2019.03.22.06.17.53; Fri, 22 Mar 2019 06:18:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oVWfdfkR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729497AbfCVNRH (ORCPT + 99 others); Fri, 22 Mar 2019 09:17:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:53394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729329AbfCVLZv (ORCPT ); Fri, 22 Mar 2019 07:25:51 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 46BDB20657; Fri, 22 Mar 2019 11:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253950; bh=857of64xX2ThGZuP6WE6cbvz+Tuy+NnKivHydK4shck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oVWfdfkRTt5N9RLA/5sJK7PfWEvXpDu/tC3K3pbwIvmnKgKQkVL6NtfeZJHVWQkga qbvrl76SGSvu+oPThU6sZAHUD4YaLQCwBHJF9z9GzSik6L89IYjAtH9gqbAkkNGO4L wcjTWUCUMgPZlLYKvQZIapVlpQPR1v5LrmYgILus= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org Subject: [PATCH 3.18 113/134] scsi: target/iscsi: Avoid iscsit_release_commands_from_conn() deadlock Date: Fri, 22 Mar 2019 12:15:26 +0100 Message-Id: <20190322111218.496023664@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bart Van Assche 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): [] __local_bh_enable_ip+0xa9/0x160 hardirqs last disabled at (1281): [] interrupt_entry+0xb5/0xd0 softirqs last enabled at (1278): [] lock_sock_nested+0x51/0xc0 softirqs last disabled at (1280): [] 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); 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 @@ -4198,9 +4198,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);