fix CVE-2024-38796

This commit is contained in:
zhangxianting 2024-10-09 16:19:00 +08:00
parent cb896133d1
commit b20cd02e38
2 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,32 @@
From c95233b8525ca6828921affd1496146cff262e65 Mon Sep 17 00:00:00 2001
From: Doug Flick <dougflick@microsoft.com>
Date: Fri, 27 Sep 2024 12:08:55 -0700
Subject: [PATCH] MdePkg: Fix overflow issue in BasePeCoffLib
The RelocDir->Size is a UINT32 value, and RelocDir->VirtualAddress is
also a UINT32 value. The current code does not check for overflow when
adding RelocDir->Size to RelocDir->VirtualAddress. This patch adds a
check to ensure that the addition does not overflow.
Signed-off-by: Doug Flick <dougflick@microsoft.com>
Authored-by: sriraamx gobichettipalayam <sri..@intel.com>
---
MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
index 1102833..7fa4714 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
@@ -991,7 +991,7 @@ PeCoffLoaderRelocateImage (
RelocDir = &Hdr.Te->DataDirectory[0];
}
- if ((RelocDir != NULL) && (RelocDir->Size > 0)) {
+ if ((RelocDir != NULL) && (RelocDir->Size > 0) && (RelocDir->Size - 1 < MAX_UINT32 - RelocDir->VirtualAddress)) {
RelocBase = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress, TeStrippedOffset);
RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) PeCoffLoaderImageAddress (ImageContext,
RelocDir->VirtualAddress + RelocDir->Size - 1,
--
2.43.0

View File

@ -5,7 +5,7 @@
Name: edk2
Version: %{stable_date}
Release: 20
Release: 21
Summary: EFI Development Kit II
License: BSD-2-Clause-Patent
URL: https://github.com/tianocore/edk2
@ -126,6 +126,9 @@ Patch0086: 0086-Fix-NETSCAPE_SPKI_print-function-to-not-assume-NUL-t.patch
Patch0087: 0087-Fix-EC_GROUP_new_from_ecparameters-to-check-the-base.patch
Patch0088: 0088-Fix-possible-infinite-loop-in-BN_mod_sqrt.patch
# Fix CVE-2024-38796
patch0089: 0089-MdePkg-Fix-overflow-issue-in-BasePeCoffLib.patch
BuildRequires: acpica-tools gcc gcc-c++ libuuid-devel python3 bc nasm python3-unversioned-command
%description
@ -326,6 +329,9 @@ chmod +x %{buildroot}%{_bindir}/Rsa2048Sha256GenerateKeys
%endif
%changelog
* Wed Oct 09 2024 zhangxianting <zhangxianting@uniontech.com> - 202011-21
- fix CVE-2024-38796
* Tue Sep 3 2024 shenyage<shenyage1@huawei.com> - 202011-20
- fix CVE-2021-3712、CVE-2022-0778