From: Kinney, Michael D Date: Wed, 7 Feb 2018 01:43:32 +0000 (-0800) Subject: MdeModulePkg/DxeCapsuleLibFmp: Verify nested capsule with FMP X-Git-Tag: edk2-stable201903~2379 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=7f0301e39a11852c8c26b6a700f0a3a0c381e95c;hp=48ed4769fcfb524315d60ff745973ea3c8525ff5 MdeModulePkg/DxeCapsuleLibFmp: Verify nested capsule with FMP https://bugzilla.tianocore.org/show_bug.cgi?id=873 Update IsNestedFmpCapsule() to verify the CapsuleGuid in the CapsuleHeader against the installed Firmware Management Protocol instances. The current logic that uses the ESRT Table does not work because capsules are processed before the ESRT Table is published at the Ready To Boot event. Cc: Jiewen Yao Cc: Star Zeng Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-by: Jiewen Yao Reviewed-by: Star Zeng Reviewed-by: Bret Barkelew --- diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index 56c8e98b84..15dbc00216 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -1190,7 +1190,6 @@ IsNestedFmpCapsule ( ) { EFI_STATUS Status; - EFI_SYSTEM_RESOURCE_TABLE *Esrt; EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry; UINTN Index; BOOLEAN EsrtGuidFound; @@ -1198,6 +1197,8 @@ IsNestedFmpCapsule ( UINTN NestedCapsuleSize; ESRT_MANAGEMENT_PROTOCOL *EsrtProtocol; EFI_SYSTEM_RESOURCE_ENTRY Entry; + EFI_HANDLE *HandleBuffer; + UINTN NumberOfHandles; EsrtGuidFound = FALSE; if (mIsVirtualAddrConverted) { @@ -1223,19 +1224,21 @@ IsNestedFmpCapsule ( } // - // Check ESRT configuration table + // Check Firmware Management Protocols // if (!EsrtGuidFound) { - Status = EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGuid, (VOID **)&Esrt); + HandleBuffer = NULL; + Status = GetFmpHandleBufferByType ( + &CapsuleHeader->CapsuleGuid, + 0, + &NumberOfHandles, + &HandleBuffer + ); if (!EFI_ERROR(Status)) { - ASSERT (Esrt != NULL); - EsrtEntry = (VOID *)(Esrt + 1); - for (Index = 0; Index < Esrt->FwResourceCount; Index++, EsrtEntry++) { - if (CompareGuid(&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) { - EsrtGuidFound = TRUE; - break; - } - } + EsrtGuidFound = TRUE; + } + if (HandleBuffer != NULL) { + FreePool (HandleBuffer); } } } diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf index 9eb50337a2..1d947101d3 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf @@ -73,7 +73,6 @@ [Guids] gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID gWindowsUxCapsuleGuid ## SOMETIMES_CONSUMES ## GUID - gEfiSystemResourceTableGuid ## SOMETIMES_CONSUMES ## GUID ## SOMETIMES_CONSUMES ## Variable:L"CapsuleMax" ## SOMETIMES_PRODUCES ## Variable:L"CapsuleMax" gEfiCapsuleReportGuid