From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by mx.groups.io with SMTP id smtpd.web12.13821.1628451644553956410 for ; Sun, 08 Aug 2021 12:40:44 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.de header.s=2017 header.b=a5og3UH2; spf=pass (domain: posteo.de, ip: 185.67.36.66, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id A5AC1240112 for ; Sun, 8 Aug 2021 21:40:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1628451642; bh=/BqRpbSJJCJ/4MbrtHMq7ZvhYE6GS3dc1opXnMzCszg=; h=From:To:Cc:Subject:Date:From; b=a5og3UH201Yty/mCogbdnUWJR54sUBmF/lLNNTThvgeH/93z5cuZ2sJ7YNmbZnm8O ujTCToSwiNuy9LndSLIXA/4mqYTf9K5jovNKscyNddvwVWps3FY7WJiMHGQJtldATS coUHKGFHnkMtCD3ySL5tHMdDydmKihUAeesGkqaGGHpHUaDxvrWk8W9MyDyOquRhr3 WoeQG7teiEexzhfsTbFS5bRQ0L5/b2CK+4j7a6cNnXi137MMvbizgv20j+VO88vADB iMMxFWCPAypVuCXvMwa1m5jKXQdCwXPrT8s9newdfPQvOzxnmQBW9fA6b/nphr4oxQ xcBYtz6utIN1w== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4GjV1k10ymz6tmD; Sun, 8 Aug 2021 21:40:42 +0200 (CEST) From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Vitaly Cheptsov Subject: [PATCH] ArmPkg/DefaultExceptionHandlerLib: Check DebugImageInfoTable type safely Date: Sun, 8 Aug 2021 19:39:59 +0000 Message-Id: <961f3436a2b52a67aa6c8cd45c75c76835a3a5d8.1628443860.git.mhaeuser@posteo.de> In-Reply-To: <88816e99692b15cf61f3057ffab4d54455159c7c.1628443860.git.mhaeuser@posteo.de> References: <88816e99692b15cf61f3057ffab4d54455159c7c.1628443860.git.mhaeuser@posteo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable C does not allow casting to or dereferencing incompatible pointer types. Use the ImageInfoType member of the union first to determine the data type before dereferencing NormalImage. Cc: Leif Lindholm Cc: Ard Biesheuvel Cc: Vitaly Cheptsov Signed-off-by: Marvin H=C3=A4user --- ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c | = 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHand= lerUefi.c b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandl= erUefi.c index e9fea4038252..9befb6d4db9b 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi= .c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi= .c @@ -51,8 +51,8 @@ GetImageName ( =0D Address =3D (CHAR8 *)(UINTN)FaultAddress;=0D for (Entry =3D 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTab= le++) {=0D - if (DebugTable->NormalImage !=3D NULL) {=0D - if ((DebugTable->NormalImage->ImageInfoType =3D=3D EFI_DEBUG_IMAGE_I= NFO_TYPE_NORMAL) &&=0D + if (DebugTable->ImageInfoType !=3D NULL) {=0D + if ((*DebugTable->ImageInfoType =3D=3D EFI_DEBUG_IMAGE_INFO_TYPE_NOR= MAL) &&=0D (DebugTable->NormalImage->LoadedImageProtocolInstance !=3D NULL)= ) {=0D if ((Address >=3D (CHAR8 *)DebugTable->NormalImage->LoadedImagePro= tocolInstance->ImageBase) &&=0D (Address <=3D ((CHAR8 *)DebugTable->NormalImage->LoadedImagePr= otocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolIns= tance->ImageSize))) {=0D --=20 2.31.1