mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04: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:
parent
564b8e1825
commit
79eab6ffff
1 changed files with 9 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue