From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: zhichao.gao@intel.com) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by groups.io with SMTP; Tue, 20 Aug 2019 18:50:37 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Aug 2019 18:50:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,410,1559545200"; d="scan'208";a="202868351" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga004.fm.intel.com with ESMTP; 20 Aug 2019 18:50:35 -0700 Received: from shsmsx107.ccr.corp.intel.com (10.239.4.96) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 20 Aug 2019 18:50:35 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.80]) by SHSMSX107.ccr.corp.intel.com ([169.254.9.65]) with mapi id 14.03.0439.000; Wed, 21 Aug 2019 09:50:33 +0800 From: "Gao, Zhichao" To: Krzysztof Koch , "devel@edk2.groups.io" CC: "Carsey, Jaben" , "Ni, Ray" , "Sami.Mujawar@arm.com" , "Matteo.Carlini@arm.com" , "nd@arm.com" Subject: Re: [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use Thread-Topic: [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use Thread-Index: AQHVVme6U4uofLI/NEee6O/10+RxdKcE18eg Date: Wed, 21 Aug 2019 01:50:32 +0000 Message-ID: <3CE959C139B4C44DBEA1810E3AA6F9000B824805@SHSMSX101.ccr.corp.intel.com> References: <20190819082514.30936-1-krzysztof.koch@arm.com> In-Reply-To: <20190819082514.30936-1-krzysztof.koch@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: zhichao.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Zhichao Gao Thanks, Zhichao > -----Original Message----- > From: Krzysztof Koch [mailto:krzysztof.koch@arm.com] > Sent: Monday, August 19, 2019 4:25 PM > To: devel@edk2.groups.io > Cc: Carsey, Jaben ; Ni, Ray ; > Gao, Zhichao ; Sami.Mujawar@arm.com; > Matteo.Carlini@arm.com; nd@arm.com > Subject: [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global point= er > before use >=20 > Check if global pointers have been successfully updated before they are > used for further table parsing. >=20 > Signed-off-by: Krzysztof Koch > --- >=20 > Changes can be seen at: > https://github.com/KrzysztofKoch1/edk2/tree/612_add_pointer_validation_ > v2 >=20 > Notes: > v1: > - Test against NULL pointers [Krzysztof] >=20 > v2: > - Do not require FadtMinorRevision and X_DsdtAddress pointers to be > valid in order to process the remaining ACPI tables [Zhichao] >=20 > ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c > | 19 ++++++++++--------- > 1 file changed, 10 insertions(+), 9 deletions(-) >=20 > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser. > c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser. > c > index > e40c9ef8ee4b3285faf8c6edf3cb6236ee367397..6859c4824c2866fd3eb9a789a8 > dfc950724b27ca 100644 > --- > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser. > c > +++ > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtPars > +++ er.c > @@ -204,9 +204,11 @@ ParseAcpiFadt ( > ); >=20 > if (Trace) { > - Print (L"\nSummary:\n"); > - PrintFieldName (2, L"FADT Version"); > - Print (L"%d.%d\n", *AcpiHdrInfo.Revision, *FadtMinorRevision); > + if (FadtMinorRevision !=3D NULL) { > + Print (L"\nSummary:\n"); > + PrintFieldName (2, L"FADT Version"); > + Print (L"%d.%d\n", *AcpiHdrInfo.Revision, *FadtMinorRevision); > + } >=20 > if (*GetAcpiXsdtHeaderInfo ()->OemTableId !=3D *AcpiHdrInfo.OemTable= Id) > { > IncrementErrorCount (); > @@ -214,21 +216,20 @@ ParseAcpiFadt ( > } > } >=20 > - // If X_DSDT is not zero then use X_DSDT and ignore DSDT, > - // else use DSDT. > - if (*X_DsdtAddress !=3D 0) { > + // If X_DSDT is valid then use X_DSDT and ignore DSDT, else use DSDT. > + if ((X_DsdtAddress !=3D NULL) && (*X_DsdtAddress !=3D 0)) { > DsdtPtr =3D (UINT8*)(UINTN)(*X_DsdtAddress); > - } else if (*DsdtAddress !=3D 0) { > + } else if ((DsdtAddress !=3D NULL) && (*DsdtAddress !=3D 0)) { > DsdtPtr =3D (UINT8*)(UINTN)(*DsdtAddress); > } else { > - // Both DSDT and X_DSDT cannot be zero. > + // Both DSDT and X_DSDT cannot be invalid. > #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) > if (Trace) { > // The DSDT Table is mandatory for ARM systems > // as the CPU information MUST be presented in > // the DSDT. > IncrementErrorCount (); > - Print (L"ERROR: Both X_DSDT and DSDT are NULL.\n"); > + Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n"); > } > #endif > return; > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' >=20