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.100, mailfrom: nathaniel.l.desimone@intel.com) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by groups.io with SMTP; Wed, 17 Jul 2019 23:49:00 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jul 2019 23:48:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,276,1559545200"; d="scan'208";a="161985959" Received: from nldesimo-desk1.amr.corp.intel.com ([10.7.159.63]) by orsmga008.jf.intel.com with ESMTP; 17 Jul 2019 23:48:59 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Chasel Chiu , Michael A Kubacki , Sai Chaganty Subject: [edk2-platforms] [PATCH v2] KabylakeSiliconPkg: Possible out-of-bounds memory writes Date: Wed, 17 Jul 2019 23:48:34 -0700 Message-Id: <20190718064834.18100-1-nathaniel.l.desimone@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 - Add check for the DSDT not existing. - Fixed logic errors in loop boundary check. Cc: Chasel Chiu Cc: Michael A Kubacki Cc: Sai Chaganty Co-authored-by: John Mathews Signed-off-by: Nate DeSimone --- .../Library/DxeAslUpdateLib/DxeAslUpdateLib.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c b/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c index e6ab43db6d..87c6b15ed2 100644 --- a/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c +++ b/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c @@ -6,7 +6,7 @@ This library uses the ACPI Support protocol. -Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -59,6 +59,7 @@ InitializeAslUpdateLib ( @param[in] Length - length of data to be overwritten @retval EFI_SUCCESS - The function completed successfully. + @retval EFI_NOT_FOUND - Failed to locate AcpiTable. **/ EFI_STATUS UpdateNameAslCode ( @@ -72,6 +73,7 @@ UpdateNameAslCode ( UINT8 *CurrPtr; UINT32 *Signature; UINT8 *DsdtPointer; + UINT8 *EndPointer; UINTN Handle; UINT8 DataSize; @@ -99,11 +101,15 @@ UpdateNameAslCode ( /// Point to the beginning of the DSDT table /// CurrPtr = (UINT8 *) Table; + if (CurrPtr == NULL) { + return EFI_NOT_FOUND; + } /// /// Loop through the ASL looking for values that we must fix up. /// - for (DsdtPointer = CurrPtr; DsdtPointer <= (CurrPtr + ((EFI_ACPI_COMMON_HEADER *) CurrPtr)->Length); DsdtPointer++) { + EndPointer = CurrPtr + ((EFI_ACPI_COMMON_HEADER *) CurrPtr)->Length; + for (DsdtPointer = CurrPtr; DsdtPointer < EndPointer; DsdtPointer++) { /// /// Get a pointer to compare for signature /// -- 2.17.1.windows.2