-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MdePkg: Fix overflow issue in PeCoffLoaderRelocateImageForRuntime #10617
Conversation
The SafeIntLib would be a better choice to help do this check. Also, the failure condition you have added is silent. An invalid relocation that overflows would be skipped with no messages. Should a DEBUG() message be added and should the entire relocation operation fail if this overflow condition is present? |
0943cc0
to
1361505
Compare
RelocDir->Size is a UINT32 value, and RelocDir->VirtualAddress is also a UINT32 value. The current code in PeCoffLoaderRelocateImageForRuntime does not check for overflow when adding RelocDir->Size to RelocDir->VirtualAddress. This patch uses SafeIntLib to ensure that the addition does not overflow. Signed-off-by: Sachin Ganesh <sachinganesh@ami.com>
Used SafeIntLib to handle the overflow check in PeCoffLoaderRelocateImage Signed-off-by: Sachin Ganesh <sachinganesh@ami.com>
1361505
to
b0b3af2
Compare
For the build failures, I recommend adding a mapping of
|
SafeIntLib has been added to UnitTestFrameworkPkg Common Includes DSC for usage in host and target based tests. Signed-off-by: Sachin Ganesh <sachinganesh@ami.com>
Thank you for your guidance @mdkinney |
@mergify refresh |
✅ Pull request refreshed |
This series breaks the build on Clang:
Please provide a fix asap |
Fixed in #10689 |
Description
Similar to #6249
RelocDir->Size is a UINT32 value, and RelocDir->VirtualAddress is also a UINT32 value. The current code in
PeCoffLoaderRelocateImageForRuntime() does not check for overflow when adding RelocDir->Size to RelocDir->VirtualAddress. This patch adds a check using SafeIntLib to ensure that the addition does not overflow.
Also added SafeIntLib to UnitTestFrameworkPkg/UnitTestFrameworkPkgCommon.dsc.inc for usage in target and host based tests.
How This Was Tested
The fix has been tested in real platform and the image is confirmed to be booting fine.
Integration Instructions
N/A