mirror of
https://github.com/Dasharo/edk2.git
synced 2026-06-13 10:16:24 -07:00
StandaloneMmPkg: Avoid updating attributes on 0 length sections
PE images can have a zero virtual length section for placeholders, unused relocation, or other artifacts. At best, updated attributes on such sections is a no-op, but at worst is can cause spurious errors and asserts. Specifically asserts have been observed in Hafnium when attempting to update attributes on a zero length section. It is best to just skip such sections entirely. This commit simply logs and skips these sections explicitly. Signed-off-by: Chris Fernald <chfernal@microsoft.com>
This commit is contained in:
committed by
mergify[bot]
parent
564b8e1825
commit
79eab6ffff
+9
-1
@@ -164,7 +164,15 @@ UpdatePeCoffPermissions (
|
||||
|
||||
Base = TmpContext.ImageAddress + SectionHeader.VirtualAddress;
|
||||
|
||||
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_EXECUTE) == 0) {
|
||||
if (SectionHeader.Misc.VirtualSize == 0) {
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Skipping section %d of image at 0x%lx with size 0\n",
|
||||
__func__,
|
||||
Index,
|
||||
Base
|
||||
));
|
||||
} else if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_EXECUTE) == 0) {
|
||||
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_WRITE) == 0) {
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
|
||||
Reference in New Issue
Block a user