From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web12.12689.1575906468331519290 for ; Mon, 09 Dec 2019 07:47:48 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: chao.b.zhang@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Dec 2019 07:47:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,296,1571727600"; d="scan'208";a="412803080" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga005.fm.intel.com with ESMTP; 09 Dec 2019 07:47:47 -0800 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 9 Dec 2019 07:47:47 -0800 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 9 Dec 2019 07:47:46 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.109]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.46]) with mapi id 14.03.0439.000; Mon, 9 Dec 2019 23:47:45 +0800 From: "Zhang, Chao B" To: "Yao, Jiewen" , "devel@edk2.groups.io" CC: "Wang, Jian J" Subject: Re: [PATCH] SecurityPkg/Tcg2Smm: Measure the table before patch. Thread-Topic: [PATCH] SecurityPkg/Tcg2Smm: Measure the table before patch. Thread-Index: AQHVrQRt57SzkEpi80+N/d9U/ftetaex9aow Date: Mon, 9 Dec 2019 15:47:44 +0000 Message-ID: References: <20191207134356.2412-1-jiewen.yao@intel.com> In-Reply-To: <20191207134356.2412-1-jiewen.yao@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNmU0ZTMyYmEtMjhiZS00ZDFkLThlZGYtYmUxMWQyZDY1ODYwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiV0VmNVwvdERIV29vb1JZZDlDdHlrUDZmbXlRajM4YWNIVmFkbEVZXC9qaVJqM2RZZlJVbjZkU2NlNkl6aGt1WEZhIn0= dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: chao.b.zhang@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Jiewen: Reviewed-by: Chao Zhang -----Original Message----- From: Yao, Jiewen =20 Sent: Saturday, December 7, 2019 9:44 PM To: devel@edk2.groups.io Cc: Wang, Jian J ; Zhang, Chao B ; Yao, Jiewen Subject: [PATCH] SecurityPkg/Tcg2Smm: Measure the table before patch. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1940 According to TCG PFP specification: the ACPI table must be measured prior t= o any modification, and the measurement must be same cross every boot cycle= . There is a fix 3a63c17ebc853cbb27d190729d01e27f68e65b94 for the HID data. However that is not enough. The LAML/LASA and PCD configuration change may also cause similar problem. We need measure the table before any update. Cc: Jian J Wang Cc: Chao Zhang Signed-off-by: Jiewen Yao --- SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 57 ++++++++++++++++--------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c b/SecurityPkg/Tcg/Tcg2Smm/Tc= g2Smm.c index 54966c83ce..91aebb62b8 100644 --- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c +++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c @@ -651,23 +651,11 @@ PublishAcpiTable ( ); ASSERT_EFI_ERROR (Status); =20 - // - // Update Table version before measuring it to PCR - // - Status =3D UpdatePPVersion(Table, (CHAR8 *)PcdGetPtr(PcdTcgPhysicalPrese= nceInterfaceVer)); - ASSERT_EFI_ERROR (Status); - - DEBUG (( - DEBUG_INFO, - "Current physical presence interface version - %a\n", - (CHAR8 *) PcdGetPtr(PcdTcgPhysicalPresenceInterfaceVer) - )); - // // Measure to PCR[0] with event EV_POST_CODE ACPI DATA. - // The measurement has to be done before UpdateHID since TPM2 ACPI HID - // imply TPM Firmware Version. Otherwise, the PCR record would be - // different after TPM FW update. + // The measurement has to be done before any update. + // Otherwise, the PCR record would be different after TPM FW update =20 + // or the PCD configuration change. // TpmMeasureAndLogData( 0, @@ -678,6 +666,18 @@ PublishAcpiTable ( TableSize ); =20 + // + // Update Table version before measuring it to PCR // Status =3D=20 + UpdatePPVersion(Table, (CHAR8=20 + *)PcdGetPtr(PcdTcgPhysicalPresenceInterfaceVer)); + ASSERT_EFI_ERROR (Status); + + DEBUG (( + DEBUG_INFO, + "Current physical presence interface version - %a\n", + (CHAR8 *) PcdGetPtr(PcdTcgPhysicalPresenceInterfaceVer) + )); + // // Update TPM2 HID after measuring it to PCR // @@ -753,6 +753,21 @@ PublishTpm2 ( EFI_TPM2_ACPI_CONTROL_AREA *ControlArea; TPM2_PTP_INTERFACE_TYPE InterfaceType; =20 + // + // Measure to PCR[0] with event EV_POST_CODE ACPI DATA. + // The measurement has to be done before any update. + // Otherwise, the PCR record would be different after event log=20 + update // or the PCD configuration change. + // + TpmMeasureAndLogData( + 0, + EV_POST_CODE, + EV_POSTCODE_INFO_ACPI_DATA, + ACPI_DATA_LEN, + &mTpm2AcpiTemplate, + mTpm2AcpiTemplate.Header.Length + ); + mTpm2AcpiTemplate.Header.Revision =3D PcdGet8(PcdTpm2AcpiTableRev); DEBUG((DEBUG_INFO, "Tpm2 ACPI table revision is %d\n", mTpm2AcpiTemplate= .Header.Revision)); =20 @@ -776,18 +791,6 @@ PublishTpm2 ( mTpm2AcpiTemplate.Header.Length =3D sizeof(EFI_TPM2_ACPI_TABLE); } =20 - // - // Measure to PCR[0] with event EV_POST_CODE ACPI DATA - // - TpmMeasureAndLogData( - 0, - EV_POST_CODE, - EV_POSTCODE_INFO_ACPI_DATA, - ACPI_DATA_LEN, - &mTpm2AcpiTemplate, - mTpm2AcpiTemplate.Header.Length - ); - InterfaceType =3D PcdGet8(PcdActiveTpmInterfaceType); switch (InterfaceType) { case Tpm2PtpInterfaceCrb: -- 2.19.2.windows.1