From patchwork Thu May 18 07:58:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nilesh Javali X-Patchwork-Id: 13246266 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20494C77B7D for ; Thu, 18 May 2023 07:58:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229694AbjERH6w (ORCPT ); Thu, 18 May 2023 03:58:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbjERH6v (ORCPT ); Thu, 18 May 2023 03:58:51 -0400 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEF851FE8 for ; Thu, 18 May 2023 00:58:49 -0700 (PDT) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34I7HBkG004534 for ; Thu, 18 May 2023 00:58:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=vyqA+968Q2J/pa5licXy9hgFul+fFkQiqowy81dDv6I=; b=dyAhKwXBum0naX3Ew+OMx48vmuOQL/tcwlweY1rZZ1t8g8hdaZhs9H1y/cHea7BoMFol n4uZ0eQHLGSg6CzFf7VTPO13teb5SpO0DgENUZI55HHaNePHY1IkGYlpizYVnaPhKrGc K+D3fiAeWvsVhauCzwM4gwBooPAqMb4vLYvo5eSTU/bP9o5u+Wneq/D82Ll54592701E iMYpFuKIPoxRoDbWcUK+Zs7zxPXbHS+/SETWFH2lzubjYd1UCX5F7uEx+D+rHhqgKnwh SMJ0sz8PhnMNDFDOvrD9uIFHyi/Y+G4DoDxgNdWGFX29y706uIhKmyVPZy0NfW7yEATA xg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3qmyexb9fp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 18 May 2023 00:58:49 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 18 May 2023 00:58:46 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 18 May 2023 00:58:46 -0700 Received: from localhost.marvell.com (unknown [10.30.46.195]) by maili.marvell.com (Postfix) with ESMTP id CAFD73F704C; Thu, 18 May 2023 00:58:44 -0700 (PDT) From: Nilesh Javali To: CC: , , , , Subject: [PATCH 1/8] qla2xxx: klocwork - Array index may go out of bound Date: Thu, 18 May 2023 13:28:34 +0530 Message-ID: <20230518075841.40363-2-njavali@marvell.com> X-Mailer: git-send-email 2.23.1 In-Reply-To: <20230518075841.40363-1-njavali@marvell.com> References: <20230518075841.40363-1-njavali@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: pdR_j8qDx8tDNlekwmcerj1-0aRnT4pI X-Proofpoint-ORIG-GUID: pdR_j8qDx8tDNlekwmcerj1-0aRnT4pI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-18_05,2023-05-17_02,2023-02-09_01 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Klocwork reports array 'vha->host_str' of size 16 may use index value(s) 16..19. Use snprintf instead of sprintf. Cc: stable@vger.kernel.org Signed-off-by: Bikash Hazarika Signed-off-by: Nilesh Javali --- drivers/scsi/qla2xxx/qla_os.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index bc89d3da8fd0..3bace9ea6288 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -5088,7 +5088,8 @@ struct scsi_qla_host *qla2x00_create_host(const struct scsi_host_template *sht, } INIT_DELAYED_WORK(&vha->scan.scan_work, qla_scan_work_fn); - sprintf(vha->host_str, "%s_%lu", QLA2XXX_DRIVER_NAME, vha->host_no); + snprintf(vha->host_str, sizeof(vha->host_str), "%s_%lu", + QLA2XXX_DRIVER_NAME, vha->host_no); ql_dbg(ql_dbg_init, vha, 0x0041, "Allocated the host=%p hw=%p vha=%p dev_name=%s", vha->host, vha->hw, vha, From patchwork Thu May 18 07:58:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nilesh Javali X-Patchwork-Id: 13246267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFDA7C77B7D for ; Thu, 18 May 2023 07:58:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbjERH64 (ORCPT ); Thu, 18 May 2023 03:58:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbjERH6y (ORCPT ); Thu, 18 May 2023 03:58:54 -0400 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCDA91FE8 for ; Thu, 18 May 2023 00:58:53 -0700 (PDT) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34I7GuQH003572 for ; Thu, 18 May 2023 00:58:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=7wDXHUJyDG+hJ8eS/vdYTGHj7qFJxO5RNajIcGcaR7E=; b=OP3et20e4hfZvtBU8vHrGSjMC645W/p2Eeqg47/W+4dIroH/enl9nlJ5CU9u05MtNwnQ 6JOjJISqtI10DgmkVE8CD62utfUyXRsfNKrtfQIBfsJTvWyBRJSpSeJ0on+LZs32z7z6 ASCPugXgYaOZ0qaGtCzj6hBTe4omFzEBm1AYUH1/yp9YxkgZF28FcmxqVybA4XCTGKyE RsBBAWjzu2e8IbRcSLvTf+ZkU0oMYv2rLxc4D8j8O5a9SwYYvUT5hsr1FPvPS4f+jbAP LC3XKTF/6lvIk4mHc66hK6QvIT8UY5G+2pFKbUBspeu7woyWkwhb4RffNBGYvj5+eVZP YA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3qmyexb9fv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 18 May 2023 00:58:53 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 18 May 2023 00:58:50 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 18 May 2023 00:58:50 -0700 Received: from localhost.marvell.com (unknown [10.30.46.195]) by maili.marvell.com (Postfix) with ESMTP id 49E163F704A; Thu, 18 May 2023 00:58:47 -0700 (PDT) From: Nilesh Javali To: CC: , , , , Subject: [PATCH 2/8] qla2xxx: klocwork - Fix potential null pointer dereference Date: Thu, 18 May 2023 13:28:35 +0530 Message-ID: <20230518075841.40363-3-njavali@marvell.com> X-Mailer: git-send-email 2.23.1 In-Reply-To: <20230518075841.40363-1-njavali@marvell.com> References: <20230518075841.40363-1-njavali@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: faAqk__o7WHVidMXhZiXaMsBi_-V3uVC X-Proofpoint-ORIG-GUID: faAqk__o7WHVidMXhZiXaMsBi_-V3uVC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-18_05,2023-05-17_02,2023-02-09_01 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bikash Hazarika Klocwork tool reported 'cur_dsd' may be dereferenced. Add fix to validate pointer before dereferencing the pointer. Cc: stable@vger.kernel.org Signed-off-by: Bikash Hazarika Signed-off-by: Nilesh Javali --- drivers/scsi/qla2xxx/qla_iocb.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 6acfdcc48b16..a092151aef77 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -664,9 +664,11 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt, } /* Null termination */ - cur_dsd->address = 0; - cur_dsd->length = 0; - cur_dsd++; + if (cur_dsd) { + cur_dsd->address = 0; + cur_dsd->length = 0; + cur_dsd++; + } cmd_pkt->control_flags |= cpu_to_le16(CF_DATA_SEG_DESCR_ENABLE); return 0; } From patchwork Thu May 18 07:58:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nilesh Javali X-Patchwork-Id: 13246268 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8782AC77B7A for ; Thu, 18 May 2023 07:58:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229651AbjERH66 (ORCPT ); Thu, 18 May 2023 03:58:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229747AbjERH64 (ORCPT ); Thu, 18 May 2023 03:58:56 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CACA2693 for ; Thu, 18 May 2023 00:58:56 -0700 (PDT) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34HMFcTR013246 for ; Thu, 18 May 2023 00:58:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=lyBGX0REEjHE8IqNlfVSKXXkCsxidg4NnY59Bbd49Lw=; b=ecYXybqUQTaG45+fh3e1qwLEiuD0Ifs/O/NWiILdCexa2WV8kC6HxQSEmlkBxYmI0R56 Qnun+dCTTOagixE3HfIAZ7oEsEQfGaHILuQjoyaQTD/YB5PhOV70Vh+NepAg1/WG9o3p T/eOZTkCJ0ky1LX/bMt9ujK7J4DrgyiB/eMmahoGGXUP8wUD96lQ1UAybqbgsZhslFuN ZqAhVezHP3LQIaihKndR/ZxnPAbpFXZexVxzQnZFTbNKWtpW5vEKVBpe4L4W9cKGJebe dwMUjHuoZeivVLW4iKA8KT8YoTXev3FrYAKuh4qm0JPTvyCg4hodfILDdHcsCHIkDkjS yQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qn7jb9rdw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 18 May 2023 00:58:55 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 18 May 2023 00:58:54 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 18 May 2023 00:58:53 -0700 Received: from localhost.marvell.com (unknown [10.30.46.195]) by maili.marvell.com (Postfix) with ESMTP id ECD0C3F7065; Thu, 18 May 2023 00:58:51 -0700 (PDT) From: Nilesh Javali To: CC: , , , , Subject: [PATCH 3/8] qla2xxx: klocwork - Check for a valid fcport pointer Date: Thu, 18 May 2023 13:28:36 +0530 Message-ID: <20230518075841.40363-4-njavali@marvell.com> X-Mailer: git-send-email 2.23.1 In-Reply-To: <20230518075841.40363-1-njavali@marvell.com> References: <20230518075841.40363-1-njavali@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: tC8RDm_awYk0k9UNaCo7Dr-ZnUxyaF15 X-Proofpoint-ORIG-GUID: tC8RDm_awYk0k9UNaCo7Dr-ZnUxyaF15 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-18_05,2023-05-17_02,2023-02-09_01 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Klocwork reported warning of null pointer may be dereferenced. The routine exits when sa_ctl is NULL and fcport is allocated after the exit call thus causing NULL fcport pointer to dereference at the time of exit. Add a check for a valid fcport pointer at the time of exit. Cc: stable@vger.kernel.org Signed-off-by: Nilesh Javali --- drivers/scsi/qla2xxx/qla_edif.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c index ec0e20255bd3..14e314c12dd6 100644 --- a/drivers/scsi/qla2xxx/qla_edif.c +++ b/drivers/scsi/qla2xxx/qla_edif.c @@ -2411,7 +2411,8 @@ qla24xx_issue_sa_replace_iocb(scsi_qla_host_t *vha, struct qla_work_evt *e) kref_put(&sp->cmd_kref, qla2x00_sp_release); fcport->flags &= ~FCF_ASYNC_SENT; done: - fcport->flags &= ~FCF_ASYNC_ACTIVE; + if (fcport) + fcport->flags &= ~FCF_ASYNC_ACTIVE; return rval; } From patchwork Thu May 18 07:58:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nilesh Javali X-Patchwork-Id: 13246269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEBD7C77B7A for ; Thu, 18 May 2023 07:59:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229778AbjERH7H (ORCPT ); Thu, 18 May 2023 03:59:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229747AbjERH67 (ORCPT ); Thu, 18 May 2023 03:58:59 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E7DE2698 for ; Thu, 18 May 2023 00:58:58 -0700 (PDT) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34HMFhQ6013340 for ; Thu, 18 May 2023 00:58:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=jejcCBY6FRlisoQiYeM/TxMrGcPV2jORAsuufAnoIMI=; b=NMwJNLH3sWegmfdCejKSwyZ0i866kf4NEhLfuZbMuI6T9oOTN2B9QXn+sGTwj6jPjTEm W8wMlVOur+pB98VBlwNYwBmoYcYbqIZyTnLodtEKFfJ9XHaDy8iAH2V/AgfQjxyIQ20z DKM1FfVePeLUMQZngWptKbr76SOIjXY54/hX6zcTS6gRa4dSnLkIn6Spd8QBkVmoBMJb vBOt5DCKN8xF90zxo37/3e4Igvcg3Jv3eF+zgyNAi3u8bbh5oRECyFvQMmYee1xccStC wvPGK9Bv18GoSLZiQX4UltgcTIIsmwkdlEPqnuAkkhLHW85mYvL+SJ5diKnRNQl9MPMI 8g== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qn7jb9rdy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 18 May 2023 00:58:58 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 18 May 2023 00:58:56 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 18 May 2023 00:58:56 -0700 Received: from localhost.marvell.com (unknown [10.30.46.195]) by maili.marvell.com (Postfix) with ESMTP id 8C65E3F7066; Thu, 18 May 2023 00:58:54 -0700 (PDT) From: Nilesh Javali To: CC: , , , , Subject: [PATCH 4/8] qla2xxx: klocwork - Check valid rport returned by fc_bsg_to_rport Date: Thu, 18 May 2023 13:28:37 +0530 Message-ID: <20230518075841.40363-5-njavali@marvell.com> X-Mailer: git-send-email 2.23.1 In-Reply-To: <20230518075841.40363-1-njavali@marvell.com> References: <20230518075841.40363-1-njavali@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: ZAsNYP67JlGcxk0-PBDP0rH-z2uIdmII X-Proofpoint-ORIG-GUID: ZAsNYP67JlGcxk0-PBDP0rH-z2uIdmII X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-18_05,2023-05-17_02,2023-02-09_01 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Klocwork reported warning of rport maybe NULL and will be dereferenced. rport returned by call to fc_bsg_to_rport could be NULL and dereferenced. Check valid rport returned by fc_bsg_to_rport. Cc: stable@vger.kernel.org Signed-off-by: Nilesh Javali --- drivers/scsi/qla2xxx/qla_bsg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index dba7bba788d7..c928b27061a9 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -283,6 +283,10 @@ qla2x00_process_els(struct bsg_job *bsg_job) if (bsg_request->msgcode == FC_BSG_RPT_ELS) { rport = fc_bsg_to_rport(bsg_job); + if (!rport) { + rval = -ENOMEM; + goto done; + } fcport = *(fc_port_t **) rport->dd_data; host = rport_to_shost(rport); vha = shost_priv(host); From patchwork Thu May 18 07:58:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nilesh Javali X-Patchwork-Id: 13246271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45475C77B7A for ; Thu, 18 May 2023 07:59:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229779AbjERH7M (ORCPT ); Thu, 18 May 2023 03:59:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbjERH7F (ORCPT ); Thu, 18 May 2023 03:59:05 -0400 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6543226A2 for ; Thu, 18 May 2023 00:59:02 -0700 (PDT) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34I7Ggd0003425 for ; Thu, 18 May 2023 00:59:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=502PJnjz9uwM4sa04gsCwmAxUMVS7kt70KMIlpfpMls=; b=Ua8D1Kb8EPK6zb3QBy6gMA+PMAk+ktJk0bybZq9+xHmi2zQpL9NAA433efxSXpiiid7x IkEC6QyESqrV5iP2GZsMw3s+2IWHetbfqE7qZpqoheIPK/QIzT/MhKrAxWHPM3Yc4qXU EDong/3rOqxWCPf5rC0oRQAZS9QmW4WaSbONur0St8sWQFwg+JALQY/NuYxSaagFKIfg 8Yt372wWBxm5dit+MemmsBG/XsXslYCq4CMwivJauRDaq9NwRDFWqIzwfqKfkOjyuAjn 6X6QCl0EfpxQFdD7D0wjA0T+Z1Yi/Nqu4rdMl1wq5DT9UtdPtb8gZyLqJYCVBtTx9g+c fA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3qmyexb9gf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 18 May 2023 00:59:01 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 18 May 2023 00:58:59 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 18 May 2023 00:58:58 -0700 Received: from localhost.marvell.com (unknown [10.30.46.195]) by maili.marvell.com (Postfix) with ESMTP id 04D9E3F7065; Thu, 18 May 2023 00:58:56 -0700 (PDT) From: Nilesh Javali To: CC: , , , , Subject: [PATCH 5/8] qla2xxx: klocwork - Fix buffer overrun Date: Thu, 18 May 2023 13:28:38 +0530 Message-ID: <20230518075841.40363-6-njavali@marvell.com> X-Mailer: git-send-email 2.23.1 In-Reply-To: <20230518075841.40363-1-njavali@marvell.com> References: <20230518075841.40363-1-njavali@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: mb8VHHUCwax0taNB39l3CxJ_ND6DqF1D X-Proofpoint-ORIG-GUID: mb8VHHUCwax0taNB39l3CxJ_ND6DqF1D X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-18_05,2023-05-17_02,2023-02-09_01 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Quinn Tran Klocwork warning: Buffer Overflow - Array Index Out of Bounds Driver uses fc_els_flogi to calculate size of buffer. The actual buffer is nested inside of fc_els_flogi which is smaller. Replace structure name to allow proper size calculation. Cc: stable@vger.kernel.org Signed-off-by: Quinn Tran Signed-off-by: Nilesh Javali --- drivers/scsi/qla2xxx/qla_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 0df6eae7324e..b0225f6f3221 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -5549,7 +5549,7 @@ static void qla_get_login_template(scsi_qla_host_t *vha) __be32 *q; memset(ha->init_cb, 0, ha->init_cb_size); - sz = min_t(int, sizeof(struct fc_els_flogi), ha->init_cb_size); + sz = min_t(int, sizeof(struct fc_els_csp), ha->init_cb_size); rval = qla24xx_get_port_login_templ(vha, ha->init_cb_dma, ha->init_cb, sz); if (rval != QLA_SUCCESS) { From patchwork Thu May 18 07:58:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nilesh Javali X-Patchwork-Id: 13246270 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5360AC77B7A for ; Thu, 18 May 2023 07:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229758AbjERH7J (ORCPT ); Thu, 18 May 2023 03:59:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229779AbjERH7G (ORCPT ); Thu, 18 May 2023 03:59:06 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71ECA26AA for ; Thu, 18 May 2023 00:59:03 -0700 (PDT) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34HMFcTT013246 for ; Thu, 18 May 2023 00:59:03 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=sh212+aZKOP180yWPyYoPPpifSn/ACLRyelMjM3Dym4=; b=GydeVj/II/J7wktfW/qbo6VIA/tiEIdPK5yvQ/17CKInCZi6f3/FGQ6qVhN6VHBumQmZ cmJUgToq8IoRGF9GMLafcwLazhas7Wo603di0K27FOgiiuQSkF2m4FCDaOqjNLKrUgmr BToCN+cKrnM3C4nArmKF32KypjSgjduM+GrhbvkN6XQSEMb3ceDfJOxU15hTiTWWj5Mx /UM0MVr0kHtnTmJX1EdU3UKTIkj7OfHOVNi0S/f6Y+voOUYbHl1VoiKdnL2ES8ezlT2g b30g9125lsL2BA4/w4OWGpArf6OFkV48UkvQe5tl0R/Une3LAQaj+ZgL18UJMDhWpCBm bA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qn7jb9re7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 18 May 2023 00:59:03 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 18 May 2023 00:59:01 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 18 May 2023 00:59:01 -0700 Received: from localhost.marvell.com (unknown [10.30.46.195]) by maili.marvell.com (Postfix) with ESMTP id 73CB53F7051; Thu, 18 May 2023 00:58:59 -0700 (PDT) From: Nilesh Javali To: CC: , , , , Subject: [PATCH 6/8] qla2xxx: klocwork - pointer may be dereferenced Date: Thu, 18 May 2023 13:28:39 +0530 Message-ID: <20230518075841.40363-7-njavali@marvell.com> X-Mailer: git-send-email 2.23.1 In-Reply-To: <20230518075841.40363-1-njavali@marvell.com> References: <20230518075841.40363-1-njavali@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: vU085AMZR-goJrdPPvp2nRJOXuE1fLqf X-Proofpoint-ORIG-GUID: vU085AMZR-goJrdPPvp2nRJOXuE1fLqf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-18_05,2023-05-17_02,2023-02-09_01 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Shreyas Deodhar Klocwork tool reported pointer 'rport' returned from call to function 'fc_bsg_to_rport' may be NULL and will be dereferenced. Add a fix to validate rport before dereferencing. Cc: stable@vger.kernel.org Signed-off-by: Shreyas Deodhar Signed-off-by: Nilesh Javali --- drivers/scsi/qla2xxx/qla_bsg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index c928b27061a9..19bb64bdd88b 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -2996,6 +2996,8 @@ qla24xx_bsg_request(struct bsg_job *bsg_job) if (bsg_request->msgcode == FC_BSG_RPT_ELS) { rport = fc_bsg_to_rport(bsg_job); + if (!rport) + return ret; host = rport_to_shost(rport); vha = shost_priv(host); } else { From patchwork Thu May 18 07:58:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nilesh Javali X-Patchwork-Id: 13246272 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32D5EC7EE24 for ; Thu, 18 May 2023 07:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229804AbjERH7P (ORCPT ); Thu, 18 May 2023 03:59:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbjERH7I (ORCPT ); Thu, 18 May 2023 03:59:08 -0400 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 168AA2696 for ; Thu, 18 May 2023 00:59:07 -0700 (PDT) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34I7HBkK004534 for ; Thu, 18 May 2023 00:59:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=gz2kUAV0N4oTn2r6hEN2JPV6zB+ZxyVELeSqmg6Ti6k=; b=jhHVsaOyvBdZG5lw9e8KvtrjXsOJT5S6fJOGh0Pxm600rnx98EgMxxQRYegWQsqAWhsn Y3Jbc527DvE+CzOaK1WmDUbEBNl4KRFT38i4v4gaunS3Rqay8VR78SqnTJl1+IlPL0iW HZgvjduvBM9LNbSMKZIWkbSKw+F5IiUev8G7ybHPXWbX5PpwlfWtvaV+5JPaNL2567fp K1J1HtVvYdHO0m+tcwu3qlZ3AYis4jOsSd58MyOe566XTppzRKUQdHJ77LdMRQdp2CxB IpN4qqPB9G2xQ6ox/ffCJS1Ug6RtO/aQTh49s8OrHy6J1Es+gbba7GCxiV8EtNfmzTSr ew== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3qmyexb9gq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 18 May 2023 00:59:06 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 18 May 2023 00:59:04 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 18 May 2023 00:59:03 -0700 Received: from localhost.marvell.com (unknown [10.30.46.195]) by maili.marvell.com (Postfix) with ESMTP id ED73F3F707E; Thu, 18 May 2023 00:59:01 -0700 (PDT) From: Nilesh Javali To: CC: , , , , Subject: [PATCH 7/8] qla2xxx: klocwork - correct the index of array Date: Thu, 18 May 2023 13:28:40 +0530 Message-ID: <20230518075841.40363-8-njavali@marvell.com> X-Mailer: git-send-email 2.23.1 In-Reply-To: <20230518075841.40363-1-njavali@marvell.com> References: <20230518075841.40363-1-njavali@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: nxOPSdlQc7EQcH_20BXujCQQnQLREnlS X-Proofpoint-ORIG-GUID: nxOPSdlQc7EQcH_20BXujCQQnQLREnlS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-18_05,2023-05-17_02,2023-02-09_01 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bikash Hazarika Klocwork reported array 'port_dstate_str' of size 10 may use index value(s) 10..15. Add a fix to correct the index of array. Cc: stable@vger.kernel.org Signed-off-by: Bikash Hazarika Signed-off-by: Nilesh Javali --- drivers/scsi/qla2xxx/qla_inline.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h index cce6e425c121..ee70cf337242 100644 --- a/drivers/scsi/qla2xxx/qla_inline.h +++ b/drivers/scsi/qla2xxx/qla_inline.h @@ -109,11 +109,13 @@ qla2x00_set_fcport_disc_state(fc_port_t *fcport, int state) { int old_val; uint8_t shiftbits, mask; + uint8_t port_dstate_str_sz; /* This will have to change when the max no. of states > 16 */ shiftbits = 4; mask = (1 << shiftbits) - 1; + port_dstate_str_sz = sizeof(port_dstate_str)/sizeof(char *); fcport->disc_state = state; while (1) { old_val = atomic_read(&fcport->shadow_disc_state); @@ -121,7 +123,8 @@ qla2x00_set_fcport_disc_state(fc_port_t *fcport, int state) old_val, (old_val << shiftbits) | state)) { ql_dbg(ql_dbg_disc, fcport->vha, 0x2134, "FCPort %8phC disc_state transition: %s to %s - portid=%06x.\n", - fcport->port_name, port_dstate_str[old_val & mask], + fcport->port_name, ((old_val & mask) < port_dstate_str_sz) ? + port_dstate_str[old_val & mask] : "Unknown", port_dstate_str[state], fcport->d_id.b24); return; } From patchwork Thu May 18 07:58:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nilesh Javali X-Patchwork-Id: 13246273 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E69DBC77B7A for ; Thu, 18 May 2023 07:59:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229758AbjERH7Z (ORCPT ); Thu, 18 May 2023 03:59:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229774AbjERH7K (ORCPT ); Thu, 18 May 2023 03:59:10 -0400 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D1B42696 for ; Thu, 18 May 2023 00:59:09 -0700 (PDT) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34I7GwSm003576 for ; Thu, 18 May 2023 00:59:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=O/tsimA+DXuNNZ7GNg4hFuClc73p2oytq70CFw2IPmc=; b=SVkoq238M+/Jmx3qMg8RxuwDQq1sJTIErQuunxpfGm8PbuROuk46UWcy3g5dV88JsKI5 eic3k1d3nkl7I2AoLIpcZXpXuLyeEG1rZ3cK56zTbIHnG9H+FAi9llI5RH5IVtIDb3w7 tJc3pji80Nyoq2iY1Rmp2NQQnhLGxanyIhe6Qs194L/eSM8euHC/7IT1aqz/CCXtcpVM ZFHjXXXR47GvILnIR1y1AA1EcJPWD66qUoDfpqsC0j7Me/5/1z+lQDA8JkBRYowUTgsp 1Gqfmr0Bwl6TtlDc0hGQubxvRH+9xTuUgRtyvyAq45YfBFjIeEejNtyfO6Cr2r38gG5y rA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3qmyexb9h0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 18 May 2023 00:59:08 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 18 May 2023 00:59:06 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 18 May 2023 00:59:06 -0700 Received: from localhost.marvell.com (unknown [10.30.46.195]) by maili.marvell.com (Postfix) with ESMTP id 71D5D3F7055; Thu, 18 May 2023 00:59:04 -0700 (PDT) From: Nilesh Javali To: CC: , , , , Subject: [PATCH 8/8] qla2xxx: Update version to 10.02.08.400-k Date: Thu, 18 May 2023 13:28:41 +0530 Message-ID: <20230518075841.40363-9-njavali@marvell.com> X-Mailer: git-send-email 2.23.1 In-Reply-To: <20230518075841.40363-1-njavali@marvell.com> References: <20230518075841.40363-1-njavali@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: R-0ik_EMq_97NEY9uGCIjwRu2Oo4UhOu X-Proofpoint-ORIG-GUID: R-0ik_EMq_97NEY9uGCIjwRu2Oo4UhOu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-18_05,2023-05-17_02,2023-02-09_01 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Signed-off-by: Nilesh Javali --- drivers/scsi/qla2xxx/qla_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h index 4d6f06fb156b..e3771923b0d7 100644 --- a/drivers/scsi/qla2xxx/qla_version.h +++ b/drivers/scsi/qla2xxx/qla_version.h @@ -6,9 +6,9 @@ /* * Driver version */ -#define QLA2XXX_VERSION "10.02.08.300-k" +#define QLA2XXX_VERSION "10.02.08.400-k" #define QLA_DRIVER_MAJOR_VER 10 #define QLA_DRIVER_MINOR_VER 2 #define QLA_DRIVER_PATCH_VER 8 -#define QLA_DRIVER_BETA_VER 300 +#define QLA_DRIVER_BETA_VER 400