From nobody Mon May 13 16:01:46 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+106997+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+106997+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1689670926; cv=none; d=zohomail.com; s=zohoarc; b=I8BqmB83FD9bRtNKKQTfFzCbgO8JvlWCykZLFhm4VkVaDE6LkLCJCbozQXDt2GQPo1EsMkijnA3e1qe/Oz7VVTmEdq+S5VYtJSdFxaG0H3prFnkMilwaBtUDqd3C09J90cuw22DOIinptf3KtbZpcpYVyzmL+3bKKVSFZf4RSHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689670926; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=8mXuYmY5nk8+jrZQ7G6NmU9pKCJE61XPZdwikuVBMps=; b=TfE5kawqA4jNTquEv0bW1PlDSWbg9MEJ+IK8TQ7it7mzp0LEsu9/zZuTArR9A58fMEvEQYJY2xjkFqTrrNGwPZWXDJdW8CL6FVcapDyk2gAUsAujinIAb1FYYwpqynmeCnUjJYpxMoZOALYNe93/XDm2/YpQpWFWSc2xiw2Gsf0= 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+106997+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1689670926643734.8643355099756; Tue, 18 Jul 2023 02:02:06 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=47SIM5o7iXrsh+q9aCez4PnaslOx9Touw86D13kHASc=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-Received:X-Gm-Message-State:X-Google-Smtp-Source:X-Received:X-Received:From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Unsubscribe:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:Content-Transfer-Encoding; s=20140610; t=1689670926; v=1; b=tXwQlGFiVJUReQWTWIV2s+9K7DjhnpvEtr76VpdUmkouDd+oaEJGFm4456woYZCKmN06SYdy j0Ht+a/aVznigYu3yNuDTK7gwz2h6YYPwgBi0RJsoq04t5jW6gsjCJbPk8DVisdLUMmoI1slc1g k0ultewLfZ0t6qXVmg69S4hw= X-Received: by 127.0.0.2 with SMTP id iblPYY1788612xBbcMkRu7nw; Tue, 18 Jul 2023 02:02:06 -0700 X-Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mx.groups.io with SMTP id smtpd.web10.5994.1689593985214362788 for ; Mon, 17 Jul 2023 04:39:45 -0700 X-Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6686a05bc66so3082833b3a.1 for ; Mon, 17 Jul 2023 04:39:45 -0700 (PDT) X-Gm-Message-State: UrMcbWrsuwfOZpA3Zj9uzKE9x1787277AA= X-Google-Smtp-Source: APBJJlHfsdECUygM6Qpu9+h79Tt2H7uJ/8dRvd1cDm9xGUAGsaZvErXJvc5hw4rksD//9z1zohTm2A== X-Received: by 2002:a17:902:e852:b0:1ba:1704:8a12 with SMTP id t18-20020a170902e85200b001ba17048a12mr12273114plg.45.1689593984521; Mon, 17 Jul 2023 04:39:44 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1cbd:8dd2:c2bf:93e0:5979:e5e0]) by smtp.gmail.com with ESMTPSA id h10-20020a170902748a00b001b830d8bc40sm12539292pll.74.2023.07.17.04.39.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 04:39:44 -0700 (PDT) From: Ranbir Singh To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Hao A Wu , Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 1/2] MdeModulePkg/Bus/Pci/PciHostBridgeDxe: Fix OVERRUN Coverity issues Date: Mon, 17 Jul 2023 17:09:36 +0530 Message-Id: <20230717113937.2290931-2-rsingh@ventanamicro.com> In-Reply-To: <20230717113937.2290931-1-rsingh@ventanamicro.com> References: <20230717113937.2290931-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689671013421100003 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: Hao A Wu 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 (#106997): https://edk2.groups.io/g/devel/message/106997 Mute This Topic: https://groups.io/mt/100212112/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 Mon May 13 16:01:46 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+106998+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+106998+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1689670926; cv=none; d=zohomail.com; s=zohoarc; b=XuoVYwS+jOqrhcgCAOXIfOsDIbRA4V6wO75zPz8vssnc6QrRzMRvYFVwgBZekCfZm6h57zdd7sTi86VmXOKvbY9SIsjE2RdjAxvOfNznUGxf2IDrGZbDGRdhQ2fQPH6py6txKxavgdrqEPooFHEEyAOZE6MN5S5QbpdiPqTWNCU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689670926; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=yCzNe3oDyc/wkPt7PXgXOcbarBkEA+dhpLG7JboGrK0=; b=BLcAhakGJiWlGO9VBpg9iQVUIum0WSRr/P3BAjGvcEBikxc5JTP9QqFs7K+h4rtKh7Bc6UN9boAmk0dFjawLXbIrOiJrRTBdGtGgcSEVn8VeLyofehhQEn3dTYUXF7JeWZBMRkjW0xeJAu4tfgByLnFx5bnzBxyoz3IYJFwZ2uQ= 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+106998+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1689670926456229.83088384959058; Tue, 18 Jul 2023 02:02:06 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=ZhIYZ15aBBH0rByQLjIRvUkH/G078qw7Z7qVQUYPbRg=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-Received:X-Gm-Message-State:X-Google-Smtp-Source:X-Received:X-Received:From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Unsubscribe:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:Content-Transfer-Encoding; s=20140610; t=1689670926; v=1; b=F0+VOZmPXMMw02cZ5VxHvuPtg9wm31SiqzoCFqlYkrmqx43qoh2n9qo2aAkrZImkq3/OnKur ZXa+NSStDknsPzSQowHSTcFyZlnE4cjeR8ArvOaCx+c8TRH4yZOnSPS+5yzQyNk3f/U2cXDVI1Y wtYzrSFEtFlIkbsrAa4Gg8Lw= X-Received: by 127.0.0.2 with SMTP id JUJeYY1788612xVuG2c30oD1; Tue, 18 Jul 2023 02:02:06 -0700 X-Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by mx.groups.io with SMTP id smtpd.web11.6033.1689593987887003885 for ; Mon, 17 Jul 2023 04:39:48 -0700 X-Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1b8ad356fe4so26507165ad.2 for ; Mon, 17 Jul 2023 04:39:47 -0700 (PDT) X-Gm-Message-State: zqZ89KaqQTlcLDLcrh4jhEJyx1787277AA= X-Google-Smtp-Source: APBJJlGR697B1HxepkNNNYCQXhkhFZfuknAD8mm38y6YrEc7jnBJHtkrDwoT92qpNK+5W4Szq//opg== X-Received: by 2002:a17:902:e852:b0:1ba:1704:8a12 with SMTP id t18-20020a170902e85200b001ba17048a12mr12273198plg.45.1689593987171; Mon, 17 Jul 2023 04:39:47 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1cbd:8dd2:c2bf:93e0:5979:e5e0]) by smtp.gmail.com with ESMTPSA id h10-20020a170902748a00b001b830d8bc40sm12539292pll.74.2023.07.17.04.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 04:39:47 -0700 (PDT) From: Ranbir Singh To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Hao A Wu , Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 2/2] MdeModulePkg/Bus/Pci/PciHostBridgeDxe: Fix MISSING_BREAK Coverity issue Date: Mon, 17 Jul 2023 17:09:37 +0530 Message-Id: <20230717113937.2290931-3-rsingh@ventanamicro.com> In-Reply-To: <20230717113937.2290931-1-rsingh@ventanamicro.com> References: <20230717113937.2290931-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689670927812100030 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 as well as any static analyzer tool. Just adding // No break; here as this is an intentional fallthrough. as comment in between makes any reader as well as Coverity happy. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4212 Cc: Hao A Wu 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 (#106998): https://edk2.groups.io/g/devel/message/106998 Mute This Topic: https://groups.io/mt/100212113/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-