Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3494000pxf; Mon, 29 Mar 2021 03:58:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNOAuGhihb46/6+6ckTH8XNNcaB+7rkHnXi664t+uRy+HBILk8HA7yc+kn5rgaCGgwOLqA X-Received: by 2002:a17:906:6882:: with SMTP id n2mr27502774ejr.50.1617015502152; Mon, 29 Mar 2021 03:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617015502; cv=none; d=google.com; s=arc-20160816; b=bnkKzBsQU/OU+aD/tQZ8/Fj6xKr2i4/s3dLyCHScBC+V+cA1sv4/JdkZFC+Vt57ouY f3MXTem9I0Nhh276ZJZ4u4guBAAXZoVamKuEb7WOxA3UM/dMzutPJDjxeAOKJNku6Jfp 6voYcc+vq/RghIAD+ZlegBzKDTm9fK2/YCXKpcdDwakt+7vvLxKaz4qikEbIGVItoxmD VAi4WoQe3fBHWij1/CIDv1TL/IK6QkMlqqmwRpUWbD+c/k1jWPiP5Gh9OQkBktB6SyoD sqzr5PyBH62xvFXz2wf43rGRYunVi2Ml7h+KF2wq0bSKLDXKUrzdG8pBDuQhs/TvePKs Kocg== 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=4pfI4lWEgWuUfaT5CmC3KQD0WCK6UfT47a8+h9iYYrg=; b=ja4UQmCGCdECsO0HIu7tXLXN6Og7NkrPZ03Y3sMktPbvwVSXDzt51ZrEOZaM5IBobM sVbmv7MAirtmuwLo/atm5zIYPljSSwMm+/HjytnL4L98EyaYfDIIsIKnwgBo1rJamLam LDT6Hk6vnqlqPStMP6Clp4ZdLYM7CVR7kIE34Xy9ukxA5D2Z7JWhJXupLzHhwPBq2F1a SfC/UMdYE1IpjYRCkpmWUBYJMnDBjsEjk9ogfe7/Dv2TNNqO18SWcXDNJRe7uiS3gR6f HBCwkuqe7tRwHoJ/E4XcyiI2s501I0KlpYtmXq6HvWT2wfmkgDxFqX5p0qP3dTQVmJtS HshA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oXAu3ylV; 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=pass (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 jl16si13489078ejc.330.2021.03.29.03.58.00; Mon, 29 Mar 2021 03:58:22 -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=@linuxfoundation.org header.s=korg header.b=oXAu3ylV; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235681AbhC2Ir0 (ORCPT + 99 others); Mon, 29 Mar 2021 04:47:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:41658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233685AbhC2IZ6 (ORCPT ); Mon, 29 Mar 2021 04:25:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8448A61996; Mon, 29 Mar 2021 08:25:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006332; bh=Sgw8TwiF/29dri5Ik1SbIf0JWfE1R6fYO5rKwkMSQ0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oXAu3ylVG9bV5RxsayuLM/hmnF4zOhitH9qX66U+JNakMIvleMHKhSFAVu8AyDDwa sd3qtYsrNLcnwZZOMn5reNfhWzGpgsQBU3VryWNCl0jrCAqSZePnN6UTSwURSJDhCM 0P/qjqzJ4756ojAEnoS6F93AGJNlmGtp55D44w30= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Quinn Tran , Mike Christie , Daniel Wagner , Himanshu Madhani , Bart Van Assche , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.10 202/221] scsi: Revert "qla2xxx: Make sure that aborted commands are freed" Date: Mon, 29 Mar 2021 09:58:53 +0200 Message-Id: <20210329075635.863447483@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@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: Bart Van Assche [ Upstream commit 39c0c8553bfb5a3d108aa47f1256076d507605e3 ] Calling vha->hw->tgt.tgt_ops->free_cmd() from qlt_xmit_response() is wrong since the command for which a response is sent must remain valid until the SCSI target core calls .release_cmd(). It has been observed that the following scenario triggers a kernel crash: - qlt_xmit_response() calls qlt_check_reserve_free_req() - qlt_check_reserve_free_req() returns -EAGAIN - qlt_xmit_response() calls vha->hw->tgt.tgt_ops->free_cmd(cmd) - transport_handle_queue_full() tries to retransmit the response Fix this crash by reverting the patch that introduced it. Link: https://lore.kernel.org/r/20210320232359.941-2-bvanassche@acm.org Fixes: 0dcec41acb85 ("scsi: qla2xxx: Make sure that aborted commands are freed") Cc: Quinn Tran Cc: Mike Christie Reviewed-by: Daniel Wagner Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/qla2xxx/qla_target.c | 13 +++++-------- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 4 ---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index a27a625839e6..dcae8f071c35 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -3222,8 +3222,7 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, if (!qpair->fw_started || (cmd->reset_count != qpair->chip_reset) || (cmd->sess && cmd->sess->deleted)) { cmd->state = QLA_TGT_STATE_PROCESSED; - res = 0; - goto free; + return 0; } ql_dbg_qp(ql_dbg_tgt, qpair, 0xe018, @@ -3234,8 +3233,9 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, res = qlt_pre_xmit_response(cmd, &prm, xmit_type, scsi_status, &full_req_cnt); - if (unlikely(res != 0)) - goto free; + if (unlikely(res != 0)) { + return res; + } spin_lock_irqsave(qpair->qp_lock_ptr, flags); @@ -3255,8 +3255,7 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, vha->flags.online, qla2x00_reset_active(vha), cmd->reset_count, qpair->chip_reset); spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); - res = 0; - goto free; + return 0; } /* Does F/W have an IOCBs for this request */ @@ -3359,8 +3358,6 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, qlt_unmap_sg(vha, cmd); spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); -free: - vha->hw->tgt.tgt_ops->free_cmd(cmd); return res; } EXPORT_SYMBOL(qlt_xmit_response); diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 61017acd3458..7405fab324c8 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -646,7 +646,6 @@ static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd) { struct qla_tgt_cmd *cmd = container_of(se_cmd, struct qla_tgt_cmd, se_cmd); - struct scsi_qla_host *vha = cmd->vha; if (cmd->aborted) { /* Cmd can loop during Q-full. tcm_qla2xxx_aborted_task @@ -659,7 +658,6 @@ static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd) cmd->se_cmd.transport_state, cmd->se_cmd.t_state, cmd->se_cmd.se_cmd_flags); - vha->hw->tgt.tgt_ops->free_cmd(cmd); return 0; } @@ -687,7 +685,6 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd) { struct qla_tgt_cmd *cmd = container_of(se_cmd, struct qla_tgt_cmd, se_cmd); - struct scsi_qla_host *vha = cmd->vha; int xmit_type = QLA_TGT_XMIT_STATUS; if (cmd->aborted) { @@ -701,7 +698,6 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd) cmd, kref_read(&cmd->se_cmd.cmd_kref), cmd->se_cmd.transport_state, cmd->se_cmd.t_state, cmd->se_cmd.se_cmd_flags); - vha->hw->tgt.tgt_ops->free_cmd(cmd); return 0; } cmd->bufflen = se_cmd->data_length; -- 2.30.1