From nobody Sun May 19 07:16:09 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+97931+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+97931+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1672829412; cv=none; d=zohomail.com; s=zohoarc; b=DFE5YgjMlakZpS86Md3HLboIozYfWzRjI/bdsA2xfEKQ2hY6PZe+z3UHEOihiY2fDzbkiCv+jX0CP1XSoAhpGPN0/H8saDJkjAVjIeAs3Eatc36a8qlL3UsHwmCeDcw3fXIzJAgHjgaSPcjHJFEYIjrljQd2NXADctjKYhmBZrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672829412; h=Content-Type:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=DO2z7YevZCkwUpDVjUNK5VX5PcAbiCl5xhky8zDSinE=; b=j5uW2BpIIvZnWEOPpCZMfvIRPN63k4XPsFxNJ8okuMa6Dwa5+RJJOMgfuANcvdQTjCYhXYD11ec1d3fT/b1BEjDj086S8Ft/+ZJOkuthAMb3agYywON6KpjvncX8ng8eGcAMS4sH+U88Lv0bMQkuimGXTh7ncnivFCQEdec7MOs= 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+97931+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1672829412595967.7843510371439; Wed, 4 Jan 2023 02:50:12 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id l8OMYY1788612xujABSNN6Uo; Wed, 04 Jan 2023 02:50:12 -0800 Subject: [edk2-devel] [PATCH] SecurityPkg/Tcg/Tcg2Config: Fix REVERSE_INULL Coverity issue To: devel@edk2.groups.io From: "Ranbir Singh via groups.io" X-Originating-Location: Bengaluru, Karnataka, IN (122.172.85.38) X-Originating-Platform: Windows Chrome 108 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Wed, 04 Jan 2023 02:50:11 -0800 Message-ID: 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,Ranbir.Singh3@Dell.com X-Gm-Message-State: z4XfffrlkfmnzKvYVwKtsSFEx1787277AA= Content-Type: multipart/alternative; boundary="0h9tUeihhw572Cz0XfsO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1672829412; bh=Vwbb2egLwjtkgKuJR8rjZ8slvCSJLbfC22IHo2Lvbk8=; h=Content-Type:Date:From:Reply-To:Subject:To; b=N4B0VTK0pM87d1ohcjJJS4KAqDDgb6gVR2N+tOJ10oLaYjiJjg0SLgMgN/TLyKzhC6+ imSRBhV8sLRq4ZsfW3zoZSt7baWirdB/IVJxQnwcWrO+k9e8cgyw4Yur4FuIJovUr/XHl +4CSvDSMvpRccZwyyr8dna7GgkU6SJ37szw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1672829414038100003 --0h9tUeihhw572Cz0XfsO Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 The function Tcg2ConfigDriverEntryPoint at the point of creating a private data structure makes a call to AllocateCopyPool and stores the return value in PrivateData. Thereafter it does a check ASSERT (PrivateData !=3D NULL); but this is applicable only in DEBUG mode. In Release mode, the code continues further and will dereference "PrivateData" which will lead to CRASH if PrivateData is NULL. Hence, for safety add PrivateData NULL pointer check and return from there saying EFI_OUT_OF_RESOURCES when PrivateData is NULL. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4229 Signed-off-by: Ranbir Singh --- SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c b/SecurityPkg/Tc= g/Tcg2Config/Tcg2ConfigDriver.c index edf5f0fc77..f023b3ccb8 100644 --- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c +++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c @@ -283,6 +283,10 @@ Tcg2ConfigDriverEntryPoint ( // PrivateData =3D AllocateCopyPool (sizeof (TCG2_CONFIG_PRIVATE_DATA), &mTcg2= ConfigPrivateDateTemplate); ASSERT (PrivateData !=3D NULL); +=C2=A0 if (PrivateData =3D=3D NULL) { +=C2=A0 =C2=A0 return EFI_OUT_OF_RESOURCES; +=C2=A0 } + mTcg2ConfigPrivateDate =3D PrivateData; // // Install private GUID. -- 2.36.1.windows.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 (#97931): https://edk2.groups.io/g/devel/message/97931 Mute This Topic: https://groups.io/mt/96047753/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- --0h9tUeihhw572Cz0XfsO Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
The function Tcg2ConfigDriverEntryPoint at the point of creating a
private data structure makes a call to AllocateCopyPool and stores
the return value in PrivateData. Thereafter it does a check
 
    ASSERT (PrivateData !=3D NULL);
 
but this is applicable only in DEBUG mode. In Release mode, the code
continues further and will dereference "PrivateData" which will lead
to CRASH if PrivateData is NULL.
 
Hence, for safety add PrivateData NULL pointer check and return from
there saying EFI_OUT_OF_RESOURCES when PrivateData is NULL.
 
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4229
Signed-off-by: Ranbir Singh <Ranbir.Singh3@Dell.com>
---
 SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c | 4 ++++
 1 file changed, 4 insertions(+)
 
diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c b/SecurityP= kg/Tcg/Tcg2Config/Tcg2ConfigDriver.c
index edf5f0fc77..f023b3ccb8 100644
--- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c
+++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c
@@ -283,6 +283,10 @@ Tcg2ConfigDriverEntryPoint (
   //
   PrivateData =3D AllocateCopyPool (sizeof (TCG2_CONFIG_PRI= VATE_DATA), &mTcg2ConfigPrivateDateTemplate);
   ASSERT (PrivateData !=3D NULL);
+  if (PrivateData =3D=3D NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
   mTcg2ConfigPrivateDate =3D PrivateData;
   //
   // Install private GUID.
--
2.36.1.windows.1
_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

= View/Reply Online (#97931) | =20 | Mute = This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [importer@patchew.org]

_._,_._,_
--0h9tUeihhw572Cz0XfsO--