Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp300460pxx; Wed, 28 Oct 2020 05:22:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCTZeK4Jjhq+lqFGuNfDfXE00X/0mNfap2CgKzKRtwGtZD6Yei5tNX4FqZEq2GQ05DYQVh X-Received: by 2002:a17:906:d78d:: with SMTP id pj13mr7126443ejb.36.1603887737372; Wed, 28 Oct 2020 05:22:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603887737; cv=none; d=google.com; s=arc-20160816; b=HtenhE9VbbkbcWY7o9JAr3DN9iqDcxa3A8TCPpvqtXnLCalTnBXnp4hRW0k7sMhdsP nHBqznXcxAqWiXpGi9wNpnjmS/oAJfFlZRXQVhVYlZyLhsY/mcWGOWLooEmAI6cxIAjN zvh2uLG5tyqqZCZTjTv/+cW6C6S6SMjT3ldtxeGMt8Yk1XM++yoc2QdNC7sCYn0tTKt6 7A5bh/63jMoxbPep7PF87lD8Y8tqthTYDym+0CmW8w9MQjho27vKj2OUuRFlee1nq9W/ L5S0AJKH36osBOU0gtcl6DitkhxduIas+oHKJ8wOUEsU5KzWrkL6uk8E0R3Jv5DyayzD kfiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=az6O1YWheGsUd93JeDu1PlzcSPlCp3nAmMi9s1YcpD0=; b=fhC4LGKz50S3SPwvWC77TV0NZKAsX5cITSBLzZprvVLGyWJkvziGbp6eJTV/nEQvpF M2tgJl0N5GwmQgvR+Gt+9Q3IzFNrDOKUGTDxO1Ui3vsji2aAc1fg6HhPOK437N1Zb/MB X/2jadPQ32xX31PxuvikyCv5Ki4DO0AbhjpUK4nFRlwe+Z+AEPrghcs1qwGxFJSiFmCb jSljC/UOhM7q9WxrpTc6Qw/SbxlAPQjJxYGOnQYWRlKhTIMOX29S3+Z12M/klx+Ohnls pIrKArY6wByb5szn7v2D/QBFdHQ8Tm0pmahBtF+MYgl20fAcpZaoJ+GnufTZZ8O9B11H uWtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BM75A++R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y19si2789537ejd.730.2020.10.28.05.21.55; Wed, 28 Oct 2020 05:22:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BM75A++R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1796681AbgJ0PTt (ORCPT + 99 others); Tue, 27 Oct 2020 11:19:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:52588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1796131AbgJ0PPv (ORCPT ); Tue, 27 Oct 2020 11:15:51 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 48B6420728; Tue, 27 Oct 2020 15:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811750; bh=DdtyPGVSGHvtTEvYrlcZowAJNLm2m8h3kmrGWS+IKvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BM75A++R05yUksyFl5hGPSM3SJ5PuhDP9bm9QsBVkdOmC3S8FZIoEfAcSAwqDcg2I 4zfVl+aQ2pgPG5AZTioxeNWQu9P4tRXAj+ru48Aku91wa1Ubx+Dj1UQ/ZjstCZcWPq gC8Q3xgliHWhrRn+EFPO1AA3T098yLyemJw4bOHs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nilesh Javali , Manish Rangankar , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.8 603/633] scsi: qedi: Protect active command list to avoid list corruption Date: Tue, 27 Oct 2020 14:55:46 +0100 Message-Id: <20201027135551.102660096@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nilesh Javali [ Upstream commit c0650e28448d606c84f76c34333dba30f61de993 ] Protect active command list for non-I/O commands like login response, logout response, text response, and recovery cleanup of active list to avoid list corruption. Link: https://lore.kernel.org/r/20200908095657.26821-5-mrangankar@marvell.com Signed-off-by: Nilesh Javali Signed-off-by: Manish Rangankar Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/qedi/qedi_fw.c | 8 ++++++++ drivers/scsi/qedi/qedi_iscsi.c | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index 946cebc4c9322..32586800620bd 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -59,6 +59,7 @@ static void qedi_process_logout_resp(struct qedi_ctx *qedi, "Freeing tid=0x%x for cid=0x%x\n", cmd->task_id, qedi_conn->iscsi_conn_id); + spin_lock(&qedi_conn->list_lock); if (likely(cmd->io_cmd_in_list)) { cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); @@ -69,6 +70,7 @@ static void qedi_process_logout_resp(struct qedi_ctx *qedi, cmd->task_id, qedi_conn->iscsi_conn_id, &cmd->io_cmd); } + spin_unlock(&qedi_conn->list_lock); cmd->state = RESPONSE_RECEIVED; qedi_clear_task_idx(qedi, cmd->task_id); @@ -122,6 +124,7 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi, "Freeing tid=0x%x for cid=0x%x\n", cmd->task_id, qedi_conn->iscsi_conn_id); + spin_lock(&qedi_conn->list_lock); if (likely(cmd->io_cmd_in_list)) { cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); @@ -132,6 +135,7 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi, cmd->task_id, qedi_conn->iscsi_conn_id, &cmd->io_cmd); } + spin_unlock(&qedi_conn->list_lock); cmd->state = RESPONSE_RECEIVED; qedi_clear_task_idx(qedi, cmd->task_id); @@ -222,11 +226,13 @@ static void qedi_process_tmf_resp(struct qedi_ctx *qedi, tmf_hdr = (struct iscsi_tm *)qedi_cmd->task->hdr; + spin_lock(&qedi_conn->list_lock); if (likely(qedi_cmd->io_cmd_in_list)) { qedi_cmd->io_cmd_in_list = false; list_del_init(&qedi_cmd->io_cmd); qedi_conn->active_cmd_count--; } + spin_unlock(&qedi_conn->list_lock); if (((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == ISCSI_TM_FUNC_LOGICAL_UNIT_RESET) || @@ -288,11 +294,13 @@ static void qedi_process_login_resp(struct qedi_ctx *qedi, ISCSI_LOGIN_RESPONSE_HDR_DATA_SEG_LEN_MASK; qedi_conn->gen_pdu.resp_wr_ptr = qedi_conn->gen_pdu.resp_buf + pld_len; + spin_lock(&qedi_conn->list_lock); if (likely(cmd->io_cmd_in_list)) { cmd->io_cmd_in_list = false; list_del_init(&cmd->io_cmd); qedi_conn->active_cmd_count--; } + spin_unlock(&qedi_conn->list_lock); memset(task_ctx, '\0', sizeof(*task_ctx)); diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index 425e665ec08b2..6e92625df4b7c 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -975,11 +975,13 @@ static void qedi_cleanup_active_cmd_list(struct qedi_conn *qedi_conn) { struct qedi_cmd *cmd, *cmd_tmp; + spin_lock(&qedi_conn->list_lock); list_for_each_entry_safe(cmd, cmd_tmp, &qedi_conn->active_cmd_list, io_cmd) { list_del_init(&cmd->io_cmd); qedi_conn->active_cmd_count--; } + spin_unlock(&qedi_conn->list_lock); } static void qedi_ep_disconnect(struct iscsi_endpoint *ep) -- 2.25.1