[edk2-devel] [edk2-platforms] [PATCH v2] KabylakeSiliconPkg: Possible out-of-bounds memory writes

Nate DeSimone posted 1 patch 4 years, 9 months ago
Failed in applying to current master (apply log)
.../Library/DxeAslUpdateLib/DxeAslUpdateLib.c          | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
[edk2-devel] [edk2-platforms] [PATCH v2] KabylakeSiliconPkg: Possible out-of-bounds memory writes
Posted by Nate DeSimone 4 years, 9 months ago
- Add check for the DSDT not existing.
- Fixed logic errors in loop boundary check.

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Michael A Kubacki <michael.a.kubacki@intel.com>
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>

Co-authored-by: John Mathews <john.mathews@intel.com>
Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 .../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.<BR>
+Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
 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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43919): https://edk2.groups.io/g/devel/message/43919
Mute This Topic: https://groups.io/mt/32512569/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [edk2-platforms] [PATCH v2] KabylakeSiliconPkg: Possible out-of-bounds memory writes
Posted by Chiu, Chasel 4 years, 9 months ago
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Nate
> DeSimone
> Sent: Thursday, July 18, 2019 2:49 PM
> To: devel@edk2.groups.io
> Cc: Chiu, Chasel <chasel.chiu@intel.com>; Kubacki, Michael A
> <michael.a.kubacki@intel.com>; Chaganty, Rangasai V
> <rangasai.v.chaganty@intel.com>
> Subject: [edk2-devel] [edk2-platforms] [PATCH v2] KabylakeSiliconPkg: Possible
> out-of-bounds memory writes
> 
> - Add check for the DSDT not existing.
> - Fixed logic errors in loop boundary check.
> 
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Michael A Kubacki <michael.a.kubacki@intel.com>
> Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
> 
> Co-authored-by: John Mathews <john.mathews@intel.com>
> Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
> ---
>  .../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/DxeAslUpd
> +++ ateLib.c
> @@ -6,7 +6,7 @@
> 
>    This library uses the ACPI Support protocol.
> 
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
>  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
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43944): https://edk2.groups.io/g/devel/message/43944
Mute This Topic: https://groups.io/mt/32512569/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [edk2-platforms] [PATCH v2] KabylakeSiliconPkg: Possible out-of-bounds memory writes
Posted by Chaganty, Rangasai V 4 years, 9 months ago
Reviewed-by: Sai Chaganty <rangasai.v.chaganty@intel.com> 

-----Original Message-----
From: Desimone, Nathaniel L 
Sent: Wednesday, July 17, 2019 11:49 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel <chasel.chiu@intel.com>; Kubacki, Michael A <michael.a.kubacki@intel.com>; Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>
Subject: [edk2-platforms] [PATCH v2] KabylakeSiliconPkg: Possible out-of-bounds memory writes

- Add check for the DSDT not existing.
- Fixed logic errors in loop boundary check.

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Michael A Kubacki <michael.a.kubacki@intel.com>
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>

Co-authored-by: John Mathews <john.mathews@intel.com>
Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 .../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/DxeAslUpd
+++ ateLib.c
@@ -6,7 +6,7 @@
 
   This library uses the ACPI Support protocol.
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
 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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43965): https://edk2.groups.io/g/devel/message/43965
Mute This Topic: https://groups.io/mt/32512569/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-