From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 664452194D3AE for ; Fri, 19 Oct 2018 04:22:30 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Oct 2018 04:22:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,399,1534834800"; d="scan'208";a="93322600" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga003.jf.intel.com with ESMTP; 19 Oct 2018 04:22:29 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 19 Oct 2018 04:22:29 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 19 Oct 2018 04:22:29 -0700 Received: from shsmsx152.ccr.corp.intel.com ([169.254.6.209]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.46]) with mapi id 14.03.0319.002; Fri, 19 Oct 2018 19:22:27 +0800 From: "Gao, Liming" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" , "Wang, Jian J" Thread-Topic: [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInSDT Thread-Index: AQHUZ4K5/kZeO7XEgUekYpYofpyPV6UmbOCQ Date: Fri, 19 Oct 2018 11:22:05 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E341F55@SHSMSX152.ccr.corp.intel.com> References: <1539936417-78404-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1539936417-78404-1-git-send-email-star.zeng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjNiNjFmM2YtOWRmOS00YTYyLTlmYzgtOTQ2ZjQ3OTgxMDYxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiV0kxZzRuRTByT3BoaHdua1ZkVUk0d3gwWE1CemdHdXlrcWgySVo5MGhCaU13bGxuRWt0WVdEYmo2UEhzWDk1USJ9 dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInSDT X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Oct 2018 11:22:30 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Zeng, Star > Sent: Friday, October 19, 2018 4:07 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Gao, Liming ;= Kinney, Michael D ; Wang, > Jian J > Subject: [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInS= DT >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1266 >=20 > af5e95215928e052445c473f1244412dadea8252 abstracted generic functions > from different modules (IntelVTdDxe, S3SaveStateDxe, PcRtc, > DpDynamicCommand and PiSmmCpuDxeSmm). Some of them (IntelVTdDxe and > PcRtc) checked Table against NULL before accessing Table->Signature, > some (S3SaveStateDxe, DpDynamicCommand and PiSmmCpuDxeSmm did not. >=20 > The ScanTableInSDT() in Acpi.c of UefiLib was mainly from > S3SaveStateDxe, so it does not check Table against NULL before > accessing Table->Signature. >=20 > This patch updates ScanTableInSDT() to check Table against NULL first > before accessing Table->Signature. >=20 > Cc: Liming Gao > Cc: Michael D Kinney > Cc: Jian J Wang > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Star Zeng > --- > MdePkg/Library/UefiLib/Acpi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/MdePkg/Library/UefiLib/Acpi.c b/MdePkg/Library/UefiLib/Acpi.= c > index 4df6731ff0a4..59a828835ca0 100644 > --- a/MdePkg/Library/UefiLib/Acpi.c > +++ b/MdePkg/Library/UefiLib/Acpi.c > @@ -67,7 +67,7 @@ ScanTableInSDT ( > EntryPtr =3D 0; > CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * TablePointerSize), Ta= blePointerSize); > Table =3D (EFI_ACPI_COMMON_HEADER *)((UINTN)(EntryPtr)); > - if (Table->Signature =3D=3D Signature) { > + if ((Table !=3D NULL) && (Table->Signature =3D=3D Signature)) { > if (PreviousTable !=3D NULL) { > if (Table =3D=3D PreviousTable) { > *PreviousTableLocated =3D TRUE; > -- > 2.7.0.windows.1