From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 90B667803E7 for ; Tue, 18 Jul 2023 09:02:14 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=7npHhUOlnw93GyY6PyMLxKBPs0R1kwfE3mzuA7kBnXI=; 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=1689670933; v=1; b=naDDIqlCeCLHgHHwRhtegyzZ0yAIu2fK/fcq+UITrU3O1ljxjGwmwyiSE1wRfNUNX5Hs+psg jwR4mrsr/veS770XQ/FPGWZZGXiFdm9IXA29h1Y2RBvmRVkBPYGJrD8SkYW2q1LRi7flwlWUP7W XYHL8yHlvCwFL2xk24d9uH4A= X-Received: by 127.0.0.2 with SMTP id 2HC8YY7687511xUv1kkicpZd; Tue, 18 Jul 2023 02:02:13 -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: PKG9YQrGacwkxowRwthaWjmhx7686176AA= 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: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=naDDIqlC; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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=4212 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/MdeModulePkg/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 ( } ASSERT (Index < TypeMax); + + if (Index >= TypeMax) { + continue; + } + ResNodeHandled[Index] = TRUE; Alignment = RootBridge->ResAllocNode[Index].Alignment; BitsOfAlignment = LowBitSet64 (Alignment + 1); -- 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- 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/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-