From nobody Thu May 16 08:17:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+110800+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110800+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1699333618; cv=none; d=zohomail.com; s=zohoarc; b=mgtHNMZuC5iUqRoCDRQnV4PqGNtWVdoFkiGpLFd2u+t30e8bLVG814DJARGq9SpjUcINdcpXN0nhljqJA+5ZwNnMgD8DaNr/5J3wCzh+U2e5uddGRGxGojuWkOSBBb5003755SG89yvaOa8XHu2w/pTQVrPjuwxjqAd5Os18zH0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699333618; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=Dkcx0qBu/Nuek9NvQWdf6JQ/NpGVULf67Sj+TfE1hlE=; b=fCAHch4/bK3KJkFksYpVLwiQZtuC6C3TT0SSjX9g3aeqlS5M5xkNdDjWYopHrojMJPy9a2kxO2Jnwy+ZStnKI3SY1piCRXc22N5QBtARxYABUPGVEDHQslWAJdtHA7vQ5L9Cgx0r9rAK4MBCLw7obdH0KHkcBLeST2c6QZ3dxvM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110800+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1699333618582483.1102661584267; Mon, 6 Nov 2023 21:06:58 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=MXtX7iBA/LyuAw4MN8VaxSP4h+Md79lECU4bVzkx6RM=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1699333618; v=1; b=XrloKAcm9Qz8nW+O9mgwChEo4CUaNVX7ssm8nuaJ70xYTPfwWZ14ro2cfqLuuIUTeOlogjKz 2VdbNYqvIZEiAN6FoX7tUubjZEZnnYKJnuFuoytYzNu/7fGZ7TFks47SL06MUjQWzqRduHRQdY3 /GPMoCObnqgVq9XyxaOEK5hg= X-Received: by 127.0.0.2 with SMTP id LobeYY1788612xAQgAEY6gke; Mon, 06 Nov 2023 21:06:58 -0800 X-Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by mx.groups.io with SMTP id smtpd.web10.4315.1699333617754989135 for ; Mon, 06 Nov 2023 21:06:57 -0800 X-Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-7a9857c14c5so191398839f.3 for ; Mon, 06 Nov 2023 21:06:57 -0800 (PST) X-Gm-Message-State: CujmksGsveK7HyDHKtMRGJaRx1787277AA= X-Google-Smtp-Source: AGHT+IFoak6WJ1lA9cvYX15l5LFVYF20htJqPAS1Rm/CeVytNN48KKnx8R7WgKj+fhbi0FpC2feOIw== X-Received: by 2002:a05:6e02:1e07:b0:357:8d71:347f with SMTP id g7-20020a056e021e0700b003578d71347fmr2331636ila.8.1699333616813; Mon, 06 Nov 2023 21:06:56 -0800 (PST) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1f24:775d:7335:84a5:7d11:9393]) by smtp.gmail.com with ESMTPSA id bu10-20020a056e02350a00b00359a2d8d0d2sm1360471ilb.67.2023.11.06.21.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 21:06:56 -0800 (PST) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v2 1/2] MdeModulePkg/Bus/Pci/PciHostBridgeDxe: Fix OVERRUN Coverity issues Date: Tue, 7 Nov 2023 10:36:46 +0530 Message-Id: <20231107050647.59613-2-rsingh@ventanamicro.com> In-Reply-To: <20231107050647.59613-1-rsingh@ventanamicro.com> References: <20231107050647.59613-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699333620593100007 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh The function NotifyPhase has a check ASSERT (Index < TypeMax); but this comes into play only in DEBUG mode. In Release mode, there is no handling if the Index value is within array limits or not. If for whatever reasons, the Index does not get re-assigned to Index2 at line 137, then it remains at TypeMax as assigned earlier at line 929. This poses array overrun risk at lines 942 and 943. It is better to deploy a safety check on Index limit before accessing array elements. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4212 Cc: Ray Ni Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c b/MdeMod= ulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c index d573e532bac8..519e1369f85e 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c @@ -939,6 +939,11 @@ NotifyPhase ( } =20 ASSERT (Index < TypeMax); + + if (Index >=3D TypeMax) { + continue; + } + ResNodeHandled[Index] =3D TRUE; Alignment =3D RootBridge->ResAllocNode[Index].Alig= nment; BitsOfAlignment =3D LowBitSet64 (Alignment + 1); --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110800): https://edk2.groups.io/g/devel/message/110800 Mute This Topic: https://groups.io/mt/102437647/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 08:17:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+110801+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110801+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1699333621; cv=none; d=zohomail.com; s=zohoarc; b=CeBw/+tD0ojLXO3H4Biq1SYWA28dRSYedqu7I15QSAU81ccdgFPaCO2kN7uzZ3hv8L8gjo4nq+hITDLR+X56IRXb02QzaQnPc81LT4SVHxpRZpLrm5xQDaz+w5Ie+G3YjXwYFe78EP0aH1NtYar/BTTfGRoKba5Cyff2HD3MOWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699333621; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=W3VppZzr22a6c2mRHC6t0mIMYBJ2O1kScs6nLK4Kruk=; b=G0V7RwRktjO9hOalcTJxIowZEfMsFVabqjcohhAHUcjeROmfe9qgHT2O7452Y/FGpWn76vHOJlvzSAKJ+bJDoR6v9ri0IaiYiPbs/t6l4AfFanPqMl0xx5C08sl5QvxDke57raplcEc8ky6lUA4z1HmCRa4TwoAOBAO8bOIUXh4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110801+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1699333621231802.0886077137786; Mon, 6 Nov 2023 21:07:01 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=dJmxzY0M412V51EYqjg7YdWMsSypXw0Ky5awrf0Ycec=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1699333620; v=1; b=i3NC2tJcwL4+O1u1qtCNk1+H7UWCR67w7aVCGXMw/iuPZSCJoMRBfVEs41Pw8LHdtsdU0gEw IFCYfxriHDGa38aDcVgaouI8u4AsTdtv9zpt5tctVvxP/1mtHDe/WGYgxk/QTGAQg6SVe/SY8Ph hgOsA69CUk89HfTMZ08ZtgJA= X-Received: by 127.0.0.2 with SMTP id AwO5YY1788612xzxYXQB5ca2; Mon, 06 Nov 2023 21:07:00 -0800 X-Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.180]) by mx.groups.io with SMTP id smtpd.web10.4317.1699333620279443546 for ; Mon, 06 Nov 2023 21:07:00 -0800 X-Received: by mail-il1-f180.google.com with SMTP id e9e14a558f8ab-35941ccaa85so22794055ab.1 for ; Mon, 06 Nov 2023 21:07:00 -0800 (PST) X-Gm-Message-State: wWhVQ3AdI649j9Nl0EXAqarZx1787277AA= X-Google-Smtp-Source: AGHT+IGbEMpwMfh1EqJkh+q7RkFrDl6MgGiKWzRxn7xLhcKXh+U5CjFzTOdc7BjlT3pM9v10KkQQuA== X-Received: by 2002:a05:6e02:1d11:b0:352:a2f8:999a with SMTP id i17-20020a056e021d1100b00352a2f8999amr2161080ila.3.1699333619251; Mon, 06 Nov 2023 21:06:59 -0800 (PST) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1f24:775d:7335:84a5:7d11:9393]) by smtp.gmail.com with ESMTPSA id bu10-20020a056e02350a00b00359a2d8d0d2sm1360471ilb.67.2023.11.06.21.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 21:06:59 -0800 (PST) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v2 2/2] MdeModulePkg/Bus/Pci/PciHostBridgeDxe: Fix MISSING_BREAK Coverity issue Date: Tue, 7 Nov 2023 10:36:47 +0530 Message-Id: <20231107050647.59613-3-rsingh@ventanamicro.com> In-Reply-To: <20231107050647.59613-1-rsingh@ventanamicro.com> References: <20231107050647.59613-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699333622590100011 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh The function SubmitResources has a switch-case code in which the case ACPI_ADDRESS_SPACE_TYPE_MEM: which falls through to case ACPI_ADDRESS_SPACE_TYPE_IO: if there is no scenario of return EFI_INVALID_PARAMETER; While this may be intentional, it is not evident to any general code reader why there is no break; in between. Adding // No break; here as this is an intentional fallthrough. as comment in between makes it explicit. Incidentally, the comment satisfies Coverity as well. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4212 Cc: Ray Ni Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c b/MdeMod= ulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c index 519e1369f85e..3bd91e2787fd 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c @@ -1531,6 +1531,10 @@ SubmitResources ( return EFI_INVALID_PARAMETER; } =20 + // + // No break; here as this is an intentional fall through. + // + case ACPI_ADDRESS_SPACE_TYPE_IO: // // Check aligment, it should be of the form 2^n-1 --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110801): https://edk2.groups.io/g/devel/message/110801 Mute This Topic: https://groups.io/mt/102437649/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-