mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-29 16:44:10 +02:00
StandaloneMmPkg/Core: Fix issue that offset calculation might be wrong
MmCoreFfsFindMmDriver() assumes FileHeader is EFI_FFS_FILE_HEADER. If FileHeader is an EFI_FFS_FILE_HEADER2, 'FileHeader + 1' will get a wrong section address. Use FfsFindSection to get the section directly, instead of 'FileHeader + 1' to avoid this issue. MmCoreFfsFindMmDriver() also assumes section is EFI_COMMON_SECTION_HEADER. If Section is EFI_COMMON_SECTION_HEADER2, 'Section + 1' will get a wrong wrong InnerFvHeader adress. Add section head detection and calculate the address accordingly. Cc: Laszlo Ersek <lersek@redhat.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Wei6 Xu <wei6.xu@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
parent
0904161f6f
commit
4a9fcab124
@ -79,8 +79,6 @@ MmCoreFfsFindMmDriver (
|
|||||||
UINTN DepexSize;
|
UINTN DepexSize;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
EFI_COMMON_SECTION_HEADER *Section;
|
EFI_COMMON_SECTION_HEADER *Section;
|
||||||
VOID *SectionData;
|
|
||||||
UINTN SectionDataSize;
|
|
||||||
UINT32 DstBufferSize;
|
UINT32 DstBufferSize;
|
||||||
VOID *ScratchBuffer;
|
VOID *ScratchBuffer;
|
||||||
UINT32 ScratchBufferSize;
|
UINT32 ScratchBufferSize;
|
||||||
@ -117,23 +115,21 @@ MmCoreFfsFindMmDriver (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = FfsFindSectionData (
|
Status = FfsFindSection (
|
||||||
EFI_SECTION_GUID_DEFINED,
|
EFI_SECTION_GUID_DEFINED,
|
||||||
FileHeader,
|
FileHeader,
|
||||||
&SectionData,
|
&Section
|
||||||
&SectionDataSize
|
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Section = (EFI_COMMON_SECTION_HEADER *)(FileHeader + 1);
|
Status = ExtractGuidedSectionGetInfo (
|
||||||
Status = ExtractGuidedSectionGetInfo (
|
Section,
|
||||||
Section,
|
&DstBufferSize,
|
||||||
&DstBufferSize,
|
&ScratchBufferSize,
|
||||||
&ScratchBufferSize,
|
&SectionAttribute
|
||||||
&SectionAttribute
|
);
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -194,8 +190,13 @@ MmCoreFfsFindMmDriver (
|
|||||||
goto FreeDstBuffer;
|
goto FreeDstBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
InnerFvHeader = (VOID *)(Section + 1);
|
if (IS_SECTION2 (Section)) {
|
||||||
Status = MmCoreFfsFindMmDriver (InnerFvHeader, Depth + 1);
|
InnerFvHeader = (VOID *)((EFI_COMMON_SECTION_HEADER2 *)Section + 1);
|
||||||
|
} else {
|
||||||
|
InnerFvHeader = (VOID *)(Section + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = MmCoreFfsFindMmDriver (InnerFvHeader, Depth + 1);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto FreeDstBuffer;
|
goto FreeDstBuffer;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user