From: "Wang, Jian J" <jian.j.wang@intel.com>
To: "Jiang, Guomin" <guomin.jiang@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Yao, Jiewen" <jiewen.yao@intel.com>,
"Zhang, Chao B" <chao.b.zhang@intel.com>,
"Zhang, Qi1" <qi1.zhang@intel.com>,
"Kumar, Rahul1" <rahul1.kumar@intel.com>
Subject: Re: [PATCH v5 6/9] SecurityPkg/Tcg2Pei: Use Migrated FV Info Hob for calculating hash (CVE-2019-11098)
Date: Mon, 13 Jul 2020 07:09:23 +0000 [thread overview]
Message-ID: <SN6PR11MB3312B33E6993A278292AD580B6600@SN6PR11MB3312.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20200709015645.336-7-guomin.jiang@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Regards,
Jian
> -----Original Message-----
> From: Jiang, Guomin <guomin.jiang@intel.com>
> Sent: Thursday, July 09, 2020 9:57 AM
> To: devel@edk2.groups.io
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>;
> Zhang, Chao B <chao.b.zhang@intel.com>; Zhang, Qi1 <qi1.zhang@intel.com>;
> Kumar, Rahul1 <rahul1.kumar@intel.com>
> Subject: [PATCH v5 6/9] SecurityPkg/Tcg2Pei: Use Migrated FV Info Hob for
> calculating hash (CVE-2019-11098)
>
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614
>
> 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.
> The Tcg2Pei calculate the hash and it use the Migrated FV Info.
>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Qi Zhang <qi1.zhang@intel.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
> ---
> SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf | 1 +
> SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 31 ++++++++++++++++++++++++++---
> 2 files changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
> b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
> index 3d361e8859e7..367df21eedaf 100644
> --- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
> +++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
> @@ -63,6 +63,7 @@ [Guids]
> gTcgEvent2EntryHobGuid ## PRODUCES ##
> HOB
> gEfiTpmDeviceInstanceNoneGuid ##
> SOMETIMES_PRODUCES ## GUID # TPM device identifier
> gEfiTpmDeviceInstanceTpm12Guid ##
> SOMETIMES_PRODUCES ## GUID # TPM device identifier
> + gEdkiiMigratedFvInfoGuid ##
> SOMETIMES_CONSUMES ## HOB
>
> [Ppis]
> gEfiPeiFirmwareVolumeInfoPpiGuid ##
> SOMETIMES_CONSUMES ## NOTIFY
> diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> index 4852d8690617..651a60c1f0e2 100644
> --- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> +++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
> @@ -21,6 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #include <Guid/TcgEventHob.h>
> #include <Guid/MeasuredFvHob.h>
> #include <Guid/TpmInstance.h>
> +#include <Guid/MigratedFvInfo.h>
>
> #include <Library/DebugLib.h>
> #include <Library/BaseMemoryLib.h>
> @@ -536,6 +537,10 @@ MeasureFvImage (
> EDKII_PEI_FIRMWARE_VOLUME_INFO_PREHASHED_FV_PPI
> *PrehashedFvPpi;
> HASH_INFO *PreHashInfo;
> UINT32 HashAlgoMask;
> + EFI_PHYSICAL_ADDRESS FvOrgBase;
> + EFI_PHYSICAL_ADDRESS FvDataBase;
> + EFI_PEI_HOB_POINTERS Hob;
> + EDKII_MIGRATED_FV_INFO *MigratedFvInfo;
>
> //
> // Check Excluded FV list
> @@ -621,6 +626,26 @@ MeasureFvImage (
> Instance++;
> } while (!EFI_ERROR(Status));
>
> + //
> + // Search the matched migration FV info
> + //
> + FvOrgBase = FvBase;
> + FvDataBase = FvBase;
> + Hob.Raw = GetFirstGuidHob (&gEdkiiMigratedFvInfoGuid);
> + while (Hob.Raw != NULL) {
> + MigratedFvInfo = GET_GUID_HOB_DATA (Hob);
> + if ((MigratedFvInfo->FvNewBase == (UINT32) FvBase) && (MigratedFvInfo-
> >FvLength == (UINT32) FvLength)) {
> + //
> + // Found the migrated FV info
> + //
> + FvOrgBase = (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo-
> >FvOrgBase;
> + FvDataBase = (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo-
> >FvDataBase;
> + break;
> + }
> + Hob.Raw = GET_NEXT_HOB (Hob);
> + Hob.Raw = GetNextGuidHob (&gEdkiiMigratedFvInfoGuid, Hob.Raw);
> + }
> +
> //
> // Init the log event for FV measurement
> //
> @@ -631,13 +656,13 @@ MeasureFvImage (
> if (FvName != NULL) {
> AsciiSPrint ((CHAR8 *)FvBlob2.BlobDescription,
> sizeof(FvBlob2.BlobDescription), "Fv(%g)", FvName);
> }
> - FvBlob2.BlobBase = FvBase;
> + FvBlob2.BlobBase = FvOrgBase;
> FvBlob2.BlobLength = FvLength;
> TcgEventHdr.EventType = EV_EFI_PLATFORM_FIRMWARE_BLOB2;
> TcgEventHdr.EventSize = sizeof (FvBlob2);
> EventData = &FvBlob2;
> } else {
> - FvBlob.BlobBase = FvBase;
> + FvBlob.BlobBase = FvOrgBase;
> FvBlob.BlobLength = FvLength;
> TcgEventHdr.PCRIndex = 0;
> TcgEventHdr.EventType = EV_EFI_PLATFORM_FIRMWARE_BLOB;
> @@ -672,7 +697,7 @@ MeasureFvImage (
> //
> Status = HashLogExtendEvent (
> 0,
> - (UINT8*) (UINTN) FvBase, // HashData
> + (UINT8*) (UINTN) FvDataBase, // HashData
> (UINTN) FvLength, // HashDataLen
> &TcgEventHdr, // EventHdr
> EventData // EventData
> --
> 2.25.1.windows.1
next prev parent reply other threads:[~2020-07-13 7:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 1:56 [PATCH v5 0/9] Add new feature that evacuate temporary to permanent memory (CVE-2019-11098) Guomin Jiang
2020-07-09 1:56 ` [PATCH v5 1/9] MdeModulePkg: Add new PCD to control the evacuate temporary memory feature (CVE-2019-11098) Guomin Jiang
2020-07-13 2:54 ` Wang, Jian J
2020-07-09 1:56 ` [PATCH v5 2/9] MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore (CVE-2019-11098) Guomin Jiang
2020-07-09 10:50 ` [edk2-devel] " Laszlo Ersek
2020-07-13 6:38 ` Wang, Jian J
2020-07-22 22:43 ` Laszlo Ersek
2020-07-09 1:56 ` [PATCH v5 3/9] UefiCpuPkg/CpuMpPei: Add GDT and IDT migration support (CVE-2019-11098) Guomin Jiang
2020-07-09 11:04 ` [edk2-devel] " Laszlo Ersek
2020-07-09 1:56 ` [PATCH v5 4/9] UefiCpuPkg/SecMigrationPei: Add initial PEIM (CVE-2019-11098) Guomin Jiang
2020-07-09 11:01 ` [edk2-devel] " Laszlo Ersek
2020-07-13 6:56 ` Wang, Jian J
2020-07-09 1:56 ` [PATCH v5 5/9] MdeModulePkg/Core: Create Migrated FV Info Hob for calculating hash (CVE-2019-11098) Guomin Jiang
2020-07-13 7:05 ` Wang, Jian J
2020-07-09 1:56 ` [PATCH v5 6/9] SecurityPkg/Tcg2Pei: Use " Guomin Jiang
2020-07-13 7:09 ` Wang, Jian J [this message]
2020-07-09 1:56 ` [PATCH v5 7/9] UefiCpuPkg/CpuMpPei: Enable paging and set NP flag to avoid TOCTOU (CVE-2019-11098) Guomin Jiang
2020-07-13 7:47 ` [edk2-devel] " Wang, Jian J
2020-07-09 1:56 ` [PATCH v5 8/9] UefiCpuPkg: Correct some typos Guomin Jiang
2020-07-09 10:58 ` [edk2-devel] " Laszlo Ersek
2020-07-09 1:56 ` [PATCH v5 9/9] SecurityPkg/TcgPei: Use Migrated FV Info Hob for calculating hash (CVE-2019-11098) Guomin Jiang
2020-07-13 7:49 ` Wang, Jian J
2020-07-10 5:46 ` [edk2-devel] [PATCH v5 0/9] Add new feature that evacuate temporary to permanent memory (CVE-2019-11098) Laszlo Ersek
2020-07-10 6:57 ` Guomin Jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=SN6PR11MB3312B33E6993A278292AD580B6600@SN6PR11MB3312.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox