From nobody Mon Feb 9 07:23:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61827+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61827+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1593501878; cv=none; d=zohomail.com; s=zohoarc; b=JVGU4XKBIKZ1Y9useO1SgFXhmc1wy8rjou+2Gvd1dFPKtr3UoSrD7Vmdryozs0SOoS0C3Jt1BNVvBGJE4xtIw+8CkyaLgn6mc5dMPSaNxZiiGUx5sxOH/+irIJvJd/xmt7tMv+nG56H/Oc6ynNHChy08CGPQ+Z4R0Iv7aYTWahs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593501878; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=l075XS04yiZoqyDZOIfxi8YZvWloyx9vveieOgF6gbQ=; b=eJ/USQDVJ9izk6CuXZJy3ZHwxf883U86KcFr9zKw2v4PuT0xOjtomRTJ2LG98CHM3ZPxvSuNuRlQk9gewoLJI6S/Zxw9Grdex8hOQUv6S8JGJOPEzF7ZNtuujO8CTVQLQf1yKQ7M6zAYx+d/klBF7SSsCvGbnnlMbJValyWH7hs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61827+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1593501878286575.4154500628604; Tue, 30 Jun 2020 00:24:38 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id XlnoYY1788612x6BHfIiGVCb; Tue, 30 Jun 2020 00:24:37 -0700 X-Received: from mga17.intel.com (mga17.intel.com []) by mx.groups.io with SMTP id smtpd.web12.10277.1593501867582751430 for ; Tue, 30 Jun 2020 00:24:37 -0700 IronPort-SDR: CdAwAlmLknh+hZCRhwaiHVGZcNTk9ujEapEcOpsH4knnxWgrwkv4tXKhoUQzm8A3mkCrd615Iv HDR1lgXooPGQ== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="126292100" X-IronPort-AV: E=Sophos;i="5.75,296,1589266800"; d="scan'208";a="126292100" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 00:24:37 -0700 IronPort-SDR: rO04sz5cu8oCzg4Yg9DIgRk2OZBATIuueyeCyiGbYeAd+UszUAEFr+1M+7gJbpM40fLfNs6Q13 Q1tF/4HKT7UA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,296,1589266800"; d="scan'208";a="320854009" X-Received: from guominji-mobl.ccr.corp.intel.com ([10.238.4.95]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jun 2020 00:24:35 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Dandan Bi , Liming Gao , Debkumar De , Harry Han , Catharine West Subject: [edk2-devel] [PATCH 5/6] MdeModulePkg/Core: Create Migrated FV Info Hob for calculating hash (CVE-2019-11098) Date: Tue, 30 Jun 2020 15:24:21 +0800 Message-Id: <20200630072422.753-6-guomin.jiang@intel.com> In-Reply-To: <20200630072422.753-1-guomin.jiang@intel.com> References: <20200630072422.753-1-guomin.jiang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,guomin.jiang@intel.com X-Gm-Message-State: Jy0sC5LI29HW3RwhalsJmjwEx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1593501877; bh=Ap6dTmiRAqZETVbyfuhgLWxE9aOzBa1vdL1EQ5UQ+5E=; h=Cc:Date:From:Reply-To:Subject:To; b=sLf089Cd/FB3xBDXo+cxvzqaxi9tPJbFu+fgm31XMlYjHVOyNdb5EP1W6J8HhU+ngje 336B4JCb5dsD94paXALsCeAL7theO0sAHpI9bGw1KRFkW56NfcSj9vzA1ZfR27CWHoRdZ LID2KE+4eJrU5I46q0cSjDkSZrGGyDNvhxE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1614 When we allocate pool to save rebased the PEIMs, the address will change randomly, therefore the hash will change and result PCR0 change as well. To avoid this, we save the raw PEIMs and use it to calculate hash. Cc: Jian J Wang Cc: Hao A Wu Cc: Dandan Bi Cc: Liming Gao Cc: Debkumar De Cc: Harry Han Cc: Catharine West Signed-off-by: Guomin Jiang --- MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 15 +++++++++++++ MdeModulePkg/Core/Pei/PeiMain.h | 1 + MdeModulePkg/Core/Pei/PeiMain.inf | 1 + MdeModulePkg/Include/Guid/MigratedFvInfo.h | 22 +++++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 3 +++ 5 files changed, 42 insertions(+) create mode 100644 MdeModulePkg/Include/Guid/MigratedFvInfo.h diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/C= ore/Pei/Dispatcher/Dispatcher.c index ef88b3423376..7e1ac38f35c8 100644 --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c @@ -1223,10 +1223,12 @@ EvacuateTempRam ( EFI_FIRMWARE_VOLUME_HEADER *FvHeader; EFI_FIRMWARE_VOLUME_HEADER *ChildFvHeader; EFI_FIRMWARE_VOLUME_HEADER *MigratedFvHeader; + EFI_FIRMWARE_VOLUME_HEADER *RawDataFvHeader; EFI_FIRMWARE_VOLUME_HEADER *MigratedChildFvHeader; =20 PEI_CORE_FV_HANDLE PeiCoreFvHandle; EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi; + EDKII_MIGRATED_FV_INFO MigratedFvInfo; =20 ASSERT (Private->PeiMemoryInstalled); =20 @@ -1270,6 +1272,13 @@ EvacuateTempRam ( ); ASSERT_EFI_ERROR (Status); =20 + Status =3D PeiServicesAllocatePages ( + EfiBootServicesCode, + EFI_SIZE_TO_PAGES ((UINTN) FvHeader->FvLength), + (EFI_PHYSICAL_ADDRESS *) &RawDataFvHeader + ); + ASSERT_EFI_ERROR (Status); + DEBUG (( DEBUG_VERBOSE, " Migrating FV[%d] from 0x%08X to 0x%08X\n", @@ -1279,6 +1288,12 @@ EvacuateTempRam ( )); =20 CopyMem (MigratedFvHeader, FvHeader, (UINTN) FvHeader->FvLength); + CopyMem (RawDataFvHeader, MigratedFvHeader, (UINTN) FvHeader->FvLeng= th); + MigratedFvInfo.FvOrgBase =3D (UINT32) (UINTN) FvHeader; + MigratedFvInfo.FvNewBase =3D (UINT32) (UINTN) MigratedFvHeader; + MigratedFvInfo.FvDataBase =3D (UINT32) (UINTN) RawDataFvHeader; + MigratedFvInfo.FvLength =3D (UINT32) (UINTN) FvHeader->FvLength; + BuildGuidDataHob (&gEdkiiMigratedFvInfoGuid, &MigratedFvInfo, sizeof= (MigratedFvInfo)); =20 // // Migrate any children for this FV now diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMai= n.h index b0101dba5e30..cbf74d5b9d9a 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.h +++ b/MdeModulePkg/Core/Pei/PeiMain.h @@ -44,6 +44,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 /// /// It is an FFS type extension used for PeiFindFileEx. It indicates curre= nt diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiM= ain.inf index 5ff14100a65f..c80d16b4efa6 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.inf +++ b/MdeModulePkg/Core/Pei/PeiMain.inf @@ -77,6 +77,7 @@ [Guids] ## CONSUMES ## GUID # Used to compare with FV's file system GUID = and get the FV's file system format gEfiFirmwareFileSystem3Guid gStatusCodeCallbackGuid + gEdkiiMigratedFvInfoGuid ## SOMETIMES_PRODUCES = ## HOB =20 [Ppis] gEfiPeiStatusCodePpiGuid ## SOMETIMES_CONSUMES # Pe= iReportStatusService is not ready if this PPI doesn't exist diff --git a/MdeModulePkg/Include/Guid/MigratedFvInfo.h b/MdeModulePkg/Incl= ude/Guid/MigratedFvInfo.h new file mode 100644 index 000000000000..061c17ed0e48 --- /dev/null +++ b/MdeModulePkg/Include/Guid/MigratedFvInfo.h @@ -0,0 +1,22 @@ +/** @file + Migrated FV information + +Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__ +#define __EDKII_MIGRATED_FV_INFO_GUID_H__ + +typedef struct { + UINT32 FvOrgBase; // original FV address + UINT32 FvNewBase; // new FV address + UINT32 FvDataBase; // original FV data + UINT32 FvLength; // Fv Length +} EDKII_MIGRATED_FV_INFO; + +extern EFI_GUID gEdkiiMigratedFvInfoGuid; + +#endif // #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__ + diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 843e963ad34b..5e25cbe98ada 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -389,6 +389,9 @@ [Guids] ## GUID indicates the capsule is to store Capsule On Disk file names. gEdkiiCapsuleOnDiskNameGuid =3D { 0x98c80a4f, 0xe16b, 0x4d11, { 0x93, 0x= 9a, 0xab, 0xe5, 0x61, 0x26, 0x3, 0x30 } } =20 + ## Include/Guid/MigratedFvInfo.h + gEdkiiMigratedFvInfoGuid =3D { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4,= 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } } + [Ppis] ## Include/Ppi/AtaController.h gPeiAtaControllerPpiGuid =3D { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0,= 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }} --=20 2.25.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61827): https://edk2.groups.io/g/devel/message/61827 Mute This Topic: https://groups.io/mt/75209409/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-