From nobody Fri May 10 11:53:31 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+107002+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+107002+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1689670929; cv=none; d=zohomail.com; s=zohoarc; b=Axoop3OCxJ5kGgMPMBfl5OgLwB1LjJoRC7w+mF2Lj0aHCl8Kq0HunAUVkabcwPN99Bch35mpE4SZXSBvXPi+zxAvXHKTPeVTC0q9M0rPJ1uxXRhiER3oV9KzUI5oW5oWE/Ok9/8FuLznsTMWv7MoJGKtvkQvVKrT3P8SzSgtQUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689670929; 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=VnaDNt2MuP7KLGOm937GwnJ0HlWbTIvBcaqfEEV9CRE=; b=n/3FWc/HYds+ZF1CUNi24I6XTcZhAsL4qw+zD95TkyeIl7QQsBAzIGZgosN31jNfl9F8yPmVtD6TB1Nvgb384P1lZPeBegCLX66GLODKhIzRWfhtYN803CcOcFELb8Nn8YDuxO1x7g/UgJZiPstWvtIyk/9z0hQZ3zizmqupH8s= 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+107002+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16896709290471000.3513961480421; Tue, 18 Jul 2023 02:02:09 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=cZ3btBviJccrioVfhgoLZgcv0PDLmv+Kf6uKS6njkYo=; 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=1689670928; v=1; b=f9iW+vmPEgQ3l1nkgiThSpPOosgqq7YzLBxBadki33iNLrVYg6w4PFoOpB11xqARzS5FmtOc o1OBW4uiLQtZBEkW+a7aXP+F6q2Gvv7lM/AFP1Pdy8zbJWuEstvlM8GwPV0NgtaysNiGSPcnyFq remaAtTf09ibnhd8y3KV0hl4= X-Received: by 127.0.0.2 with SMTP id JMSwYY1788612x6x0rLMHNPz; Tue, 18 Jul 2023 02:02:08 -0700 X-Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by mx.groups.io with SMTP id smtpd.web10.6230.1689594868065995289 for ; Mon, 17 Jul 2023 04:54:28 -0700 X-Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6831e80080dso2824494b3a.0 for ; Mon, 17 Jul 2023 04:54:28 -0700 (PDT) X-Gm-Message-State: 6G5beneeNFKl1bv1kJ1n1gf8x1787277AA= X-Google-Smtp-Source: APBJJlGyOC+q3FmAlJiDNSwAnw4x6b7He/pv+2qDdzWqzvGo5ng+0y3IxLZ+AoPu96uVPso2FQ3F5A== X-Received: by 2002:a05:6a00:c8b:b0:678:ee57:7b29 with SMTP id a11-20020a056a000c8b00b00678ee577b29mr15428069pfv.30.1689594867483; Mon, 17 Jul 2023 04:54:27 -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 d7-20020aa78147000000b0063f2a5a59d1sm11762640pfn.190.2023.07.17.04.54.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 04:54:27 -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:24:19 +0530 Message-Id: <20230717115420.2291717-2-rsingh@ventanamicro.com> In-Reply-To: <20230717115420.2291717-1-rsingh@ventanamicro.com> References: <20230717115420.2291717-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: 1689671023598100001 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 937, 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 (#107002): https://edk2.groups.io/g/devel/message/107002 Mute This Topic: https://groups.io/mt/100212116/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 Fri May 10 11:53:31 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+107003+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+107003+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1689670929; cv=none; d=zohomail.com; s=zohoarc; b=S7K/jd19ms4rUNSnj5V0YELalZj3I94a5QUlRX2O52Z7uk2VnUUgiOtYfGiYgzPxBk0we9BtoCrpb/t4OIXy5R8BP2XxKU/WhgowDksv7uFT3zNYtfWCqCEZp3dHNbXvyxc3szIVCJtUXM3Cs3f3CirgAA4gRBNKGrvdT8fsuGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689670929; 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=oaHoMqxMfFJlSzvOjpprs6CQbD8FVk2Yu5fPKqMqUw0=; b=G1kPWYLZ4vW/xF4MFDBrP+otZUGMXmoKKTlsINJjLMdaqc/IdZhf9Asyjc0RORd72gdHZ0mQ9W1uyiLMIYBlgKyDGF9R9909l60t30d9n3Rewc8N+vxSYNAy0ijKVxoO3jF0jJY8Sm+r+Tl8gU4Ok5/HqlWc2jaGLSwHNbA2WsU= 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+107003+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1689670929488105.29641851349095; Tue, 18 Jul 2023 02:02:09 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=j7tF97PY9dN6vb59mK6kOxfHLAt1aKoEknnqTeMdB1E=; 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=1689670929; v=1; b=JbgUEkIibiKkADXdF3Lq6uhbQz4VZhGbxnSFh042vKdBrDCHoCEKjzlS27cEtNY9oADcPdm2 0bweiBs/s1qAU7PANmyHYQxUwX1iwzS1T7R9Jisy0fBdvgmrBH3fKK9peyW+dvUN5aXRPWNs2kY pghnQ/mZenGjACxwQ8fjiouQ= X-Received: by 127.0.0.2 with SMTP id DvPSYY1788612xiYdUgzjpLV; Tue, 18 Jul 2023 02:02:09 -0700 X-Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mx.groups.io with SMTP id smtpd.web10.6232.1689594870329589562 for ; Mon, 17 Jul 2023 04:54:30 -0700 X-Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-666ed230c81so4556870b3a.0 for ; Mon, 17 Jul 2023 04:54:30 -0700 (PDT) X-Gm-Message-State: YoCI3Ho6lSFYFEPuZ5jeg4HBx1787277AA= X-Google-Smtp-Source: APBJJlGgu3BK3HtPhHwatdrnFHAz2yv2pH05N0ICWkbFl0VroQWSYjMGig3HlbFrFG2jPgZBJAGSSA== X-Received: by 2002:a05:6a20:9709:b0:132:cc97:9fc3 with SMTP id hr9-20020a056a20970900b00132cc979fc3mr11853215pzc.60.1689594869629; Mon, 17 Jul 2023 04:54:29 -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 d7-20020aa78147000000b0063f2a5a59d1sm11762640pfn.190.2023.07.17.04.54.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 04:54:29 -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:24:20 +0530 Message-Id: <20230717115420.2291717-3-rsingh@ventanamicro.com> In-Reply-To: <20230717115420.2291717-1-rsingh@ventanamicro.com> References: <20230717115420.2291717-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: 1689671032171100001 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 (#107003): https://edk2.groups.io/g/devel/message/107003 Mute This Topic: https://groups.io/mt/100212117/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-