[edk2-devel] [PATCH v2] [edk2-platforms] Silicon/Intel/FitGen: Fix CheckOverlap would do incorrect split BiosModule action in corner case

Lin, Jason1 posted 1 patch 1 year, 11 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
Silicon/Intel/Tools/FitGen/FitGen.c | 31 +++++++++++++++++++-
Silicon/Intel/Tools/FitGen/FitGen.h |  4 +--
2 files changed, 32 insertions(+), 3 deletions(-)
[edk2-devel] [PATCH v2] [edk2-platforms] Silicon/Intel/FitGen: Fix CheckOverlap would do incorrect split BiosModule action in corner case
Posted by Lin, Jason1 1 year, 11 months ago
From: Jason1 Lin <jason1.lin@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3922

[Description]
CheckOverlap function would do incorrect split on the BiosModule
which not happen overlap.
This would cause incorrect value locate in FIT entry record.

[Condition]
- This BiosModule base address is lower than input address.
- This BiosModule size is smaller than input size.

[Resolution]
- Do the check on BiosModule size and input size value to prevent possible
  nagative value.

Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Cc: Dakota Chiang <dakota.chiang@intel.com>
Cc: Vanessa Chuang <vanessa.chuang@intel.com>
---
 Silicon/Intel/Tools/FitGen/FitGen.c | 31 +++++++++++++++++++-
 Silicon/Intel/Tools/FitGen/FitGen.h |  4 +--
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitGen/FitGen.c
index 290e688f6e..0cdba56a48 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.c
+++ b/Silicon/Intel/Tools/FitGen/FitGen.c
@@ -2,7 +2,7 @@
 This utility is part of build process for IA32/X64 FD.
 It generates FIT table.
 
-Copyright (c) 2010-2021, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010-2022, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -755,11 +755,40 @@ CheckOverlap (
   IN UINT32 Address,
   IN UINT32 Size
   )
+/*++
+Routine Description:
+
+  Check wheather the input address and size is overlap with any BiosModule.
+  If happen overlap, need to be deal with this case.
+      ---      +--------------+ <------ BiosModule A Base           +--------------+
+       |       |              |                                     |              |
+               |              |                                     |  BiosModule  |
+               |              |                                     |      A       |
+               |              |                                     |              |
+  BiosModule A +--------------+ <------ [Input] Address     ====>   +--------------+
+      Size     |              |    |
+               |              |    |    [Input] Size
+               +--------------+  ------                             +--------------+
+               |              |                                     |  BiosModule  |
+       |       |              |                                     |      B       |
+      ---      +--------------+                                     +--------------+
+
+Arguments:
+
+  Address     - The address of the buffer that required to check.
+  Size        - The size of the buffer that required to check.
+
+Returns:
+
+  None
+
+--*/
 {
   INTN  Index;
 
   for (Index = 0; Index < (INTN)gFitTableContext.BiosModuleNumber; Index ++) {
     if ((gFitTableContext.BiosModule[Index].Address <= Address) &&
+        (gFitTableContext.BiosModule[Index].Size >= Size)       &&
         ((gFitTableContext.BiosModule[Index].Size - Size) >= (Address - gFitTableContext.BiosModule[Index].Address))) {
       UINT32  TempSize;
       INT32   SubIndex;
diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitGen/FitGen.h
index 5add6a8870..b7de0a6b2d 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.h
+++ b/Silicon/Intel/Tools/FitGen/FitGen.h
@@ -1,7 +1,7 @@
 /**@file
 Definitions for the FitGen utility.
 
-Copyright (c) 2010-2020, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010-2022, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 // Utility version information
 //
 #define UTILITY_MAJOR_VERSION 0
-#define UTILITY_MINOR_VERSION 64
+#define UTILITY_MINOR_VERSION 65
 #define UTILITY_DATE          __DATE__
 
 //
-- 
2.26.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90276): https://edk2.groups.io/g/devel/message/90276
Mute This Topic: https://groups.io/mt/91594865/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-