summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2012-07-17 01:51:26 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2012-07-17 01:51:26 +0000
commite94728b359f4e20da7fdef88a1d5123327557655 (patch)
treeb30ef3c3339292a80910c562e0fc52af6fa3a4b6 /MdeModulePkg
parent192764dba9cb61621619cbfbcbfc49834079b8f8 (diff)
downloadedk2-e94728b359f4e20da7fdef88a1d5123327557655.tar.gz
edk2-e94728b359f4e20da7fdef88a1d5123327557655.tar.bz2
edk2-e94728b359f4e20da7fdef88a1d5123327557655.zip
Update HobLib and Hob Service to avoid data over flow.
Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Rui Sun <rui.sun@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13533 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Core/Pei/Hob/Hob.c8
-rw-r--r--MdeModulePkg/Core/Pei/Memory/MemoryServices.c6
2 files changed, 10 insertions, 4 deletions
diff --git a/MdeModulePkg/Core/Pei/Hob/Hob.c b/MdeModulePkg/Core/Pei/Hob/Hob.c
index 682fa781cd..e0ee8e7f10 100644
--- a/MdeModulePkg/Core/Pei/Hob/Hob.c
+++ b/MdeModulePkg/Core/Pei/Hob/Hob.c
@@ -1,7 +1,7 @@
/** @file
This module provide Hand-Off Block manupulation.
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -89,6 +89,12 @@ PeiCreateHob (
HandOffHob = *Hob;
+ //
+ // Check Length to avoid data overflow.
+ //
+ if (0x10000 - Length <= 0x7) {
+ return EFI_INVALID_PARAMETER;
+ }
Length = (UINT16)((Length + 0x7) & (~0x7));
FreeMemory = HandOffHob->EfiFreeMemoryTop -
diff --git a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
index ded8754e85..c7a06a3c52 100644
--- a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
+++ b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
@@ -1,7 +1,7 @@
/** @file
EFI PEI Core memory services
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -249,9 +249,9 @@ PeiAllocatePool (
//
// Generally, the size of heap in temporary memory does not exceed to 64K,
- // so the maxmium size of pool is 0x10000 - sizeof (EFI_HOB_MEMORY_POOL)
+ // HobLength is multiples of 8 bytes, so the maxmium size of pool is 0xFFF8 - sizeof (EFI_HOB_MEMORY_POOL)
//
- if (Size >= (0x10000 - sizeof (EFI_HOB_MEMORY_POOL))) {
+ if (Size > (0xFFF8 - sizeof (EFI_HOB_MEMORY_POOL))) {
return EFI_OUT_OF_RESOURCES;
}