Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1366630rwi; Thu, 13 Oct 2022 12:38:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM54O9m3y3isFoB5Hy8Wf191YgtVNxKg3wC6nxS41YQxZTDE7wJc3QoY56Q7uyE03DmuFSNx X-Received: by 2002:a63:4e16:0:b0:43f:3554:ff9c with SMTP id c22-20020a634e16000000b0043f3554ff9cmr1335142pgb.578.1665689921955; Thu, 13 Oct 2022 12:38:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665689921; cv=none; d=google.com; s=arc-20160816; b=HYIrSKt8u2SGt/X0nwzc9ehDHloCK+Ya1l079iMP24mHpqvOCbInIiawpRT+/LeSH7 f+k8XSw1EA0Qpskq2hZR4Biiepp82eWZ5o9lk0C5ntoQbQSMy35cbCs8a6Hd2hOSoatz ed5GMmVRaAM0q3fk9msDwuwo1gVXUBoSFpUUVoyS8Y4tU5O08w4FlkKxMBStczokudvT aVNXoW7bPv4JHuT6rRd2qc1wADeE8DXszF6kmlZyvHYtzWE4MEWehJVSJ33Ez5Ij+cdm /9jTuiKKjsTZCxsu+qeES9jIRA0XlVqEwzrp3QyhVcRS55Wc5LZL1ewilDWaXD/G4yRT WJmQ== 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=hjDvueq1Vyq5AD0u3nIzLOc+/iWa22QCSxD/Stt9iTM=; b=KqmiMnQ9Y36uTkTGd3tzMvmZF4j6mM7tsf31IoLrzhUuk0oHfU8UEO7yXRM7/PSPRu 3zJjDWsoJHuV/VQgCEYBsCie9t6m9APsXHdB7PLajIy82TlXxeX2963ShGodrckyVWlz 7snR7QNzRlP1E4RIX3Fvc5z0cIq5EuXVBfCWVencId0ToMK0od4gKGnB4Zb7MPpKxnRg FtYqpJ4PksZp2anm4RXzWX/v6XczxNgC9j9v/cBD2VxF4ukuyXPQkeJSRA9LUZv3/3n2 2ipz1rcChA1pKDMJnLNWMel0H1bDxdokDBqyjV2yooK5mzn7TwuvlCYqHBLjh3xiXY/z cpMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MjEktAbf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h13-20020a056a00000d00b00565d7dea8bbsi283315pfk.160.2022.10.13.12.38.30; Thu, 13 Oct 2022 12:38:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MjEktAbf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229777AbiJMTGG (ORCPT + 99 others); Thu, 13 Oct 2022 15:06:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbiJMTGA (ORCPT ); Thu, 13 Oct 2022 15:06:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 430D763D7; Thu, 13 Oct 2022 12:05:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A7330B8207B; Thu, 13 Oct 2022 18:00:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 180E2C433D6; Thu, 13 Oct 2022 18:00:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684058; bh=bOidcKm6QKaIaWqZXsQBrCRpaMrW7PXqT/0Sgh+sGxk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MjEktAbfju8ST3GDa4mG/2vBcepggl7VLHD5fOZZbaHtCGGAeDKsES7EW1bV1Q6I/ h87Lfj8yHlAXREhXk2dv1gUsxcyvmwYJMVuRKBz2isxYUVpEy3Jl2MJhucb70IaNZh 9lgjkIixO6vorY7gAzCqGy2vtihc4b9HXOTJCmIQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Himanshu Madhani , Arun Easi , Nilesh Javali , "Martin K. Petersen" Subject: [PATCH 6.0 12/34] scsi: qla2xxx: Fix response queue handler reading stale packets Date: Thu, 13 Oct 2022 19:52:50 +0200 Message-Id: <20221013175146.840895989@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arun Easi commit e4f8a29deb3ba30e414dfb6b09e3ae3bf6dbe74a upstream. On some platforms, the current logic of relying on finding new packet solely based on signature pattern can lead to driver reading stale packets. Though this is a bug in those platforms, reduce such exposures by limiting reading packets until the IN pointer. Link: https://lore.kernel.org/r/20220826102559.17474-3-njavali@marvell.com Cc: stable@vger.kernel.org Reviewed-by: Himanshu Madhani Signed-off-by: Arun Easi Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qla2xxx/qla_isr.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -3763,7 +3763,8 @@ void qla24xx_process_response_queue(stru struct qla_hw_data *ha = vha->hw; struct purex_entry_24xx *purex_entry; struct purex_item *pure_item; - u16 cur_ring_index; + u16 rsp_in = 0, cur_ring_index; + int is_shadow_hba; if (!ha->flags.fw_started) return; @@ -3773,7 +3774,18 @@ void qla24xx_process_response_queue(stru qla_cpu_update(rsp->qpair, smp_processor_id()); } - while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) { +#define __update_rsp_in(_is_shadow_hba, _rsp, _rsp_in) \ + do { \ + _rsp_in = _is_shadow_hba ? *(_rsp)->in_ptr : \ + rd_reg_dword_relaxed((_rsp)->rsp_q_in); \ + } while (0) + + is_shadow_hba = IS_SHADOW_REG_CAPABLE(ha); + + __update_rsp_in(is_shadow_hba, rsp, rsp_in); + + while (rsp->ring_index != rsp_in && + rsp->ring_ptr->signature != RESPONSE_PROCESSED) { pkt = (struct sts_entry_24xx *)rsp->ring_ptr; cur_ring_index = rsp->ring_index; @@ -3887,6 +3899,7 @@ process_err: } pure_item = qla27xx_copy_fpin_pkt(vha, (void **)&pkt, &rsp); + __update_rsp_in(is_shadow_hba, rsp, rsp_in); if (!pure_item) break; qla24xx_queue_purex_item(vha, pure_item,