From nobody Mon Dec 23 10:46:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1518029391481587.0058867536367; Wed, 7 Feb 2018 10:49:51 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BA7EE2236BAAA; Wed, 7 Feb 2018 10:44:05 -0800 (PST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D391F21F0DA64 for ; Wed, 7 Feb 2018 10:44:03 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Feb 2018 10:49:47 -0800 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.241.98.55]) by fmsmga006.fm.intel.com with ESMTP; 07 Feb 2018 10:49:46 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,473,1511856000"; d="scan'208";a="202329429" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 7 Feb 2018 10:49:43 -0800 Message-Id: <20180207184943.20324-1-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 Subject: [edk2] [Patch] MdeModulePkg/DxeCapsuleLibFmp: Verify nested capsule with FMP X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Jiewen Yao , Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D873 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: Bret Barkelew Bret.Barkelew@microsoft.com Reviewed-by: Jiewen.yao@intel.com Reviewed-by: Star Zeng --- .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 27 ++++++++++++------= ---- .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf | 3 +-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeMod= ulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index 2f397789b5..87e1deec03 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -10,7 +10,7 @@ ValidateFmpCapsule(), DisplayCapsuleImage(), ConvertBmpToGopBlt() will receive untrusted input and do basic validation. =20 - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -1446,7 +1446,6 @@ IsNestedFmpCapsule ( ) { EFI_STATUS Status; - EFI_SYSTEM_RESOURCE_TABLE *Esrt; EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry; UINTN Index; BOOLEAN EsrtGuidFound; @@ -1454,6 +1453,8 @@ IsNestedFmpCapsule ( UINTN NestedCapsuleSize; ESRT_MANAGEMENT_PROTOCOL *EsrtProtocol; EFI_SYSTEM_RESOURCE_ENTRY Entry; + EFI_HANDLE *HandleBuffer; + UINTN NumberOfHandles; =20 EsrtGuidFound =3D FALSE; if (mIsVirtualAddrConverted) { @@ -1479,19 +1480,21 @@ IsNestedFmpCapsule ( } =20 // - // Check ESRT configuration table + // Check Firmware Management Protocols // if (!EsrtGuidFound) { - Status =3D EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGu= id, (VOID **)&Esrt); + HandleBuffer =3D NULL; + Status =3D GetFmpHandleBufferByType ( + &CapsuleHeader->CapsuleGuid, + 0, + &NumberOfHandles, + &HandleBuffer + ); if (!EFI_ERROR(Status)) { - ASSERT (Esrt !=3D NULL); - EsrtEntry =3D (VOID *)(Esrt + 1); - for (Index =3D 0; Index < Esrt->FwResourceCount; Index++, EsrtEntr= y++) { - if (CompareGuid(&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid= )) { - EsrtGuidFound =3D TRUE; - break; - } - } + EsrtGuidFound =3D TRUE; + } + if (HandleBuffer !=3D NULL) { + FreePool (HandleBuffer); } } } diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeM= odulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf index a7c36993c4..90edc52ee0 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf @@ -3,7 +3,7 @@ # # Capsule library instance for DXE_DRIVER module types. # -# Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at @@ -72,7 +72,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 --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel