From nobody Mon Apr 29 07:35:47 2024 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+52023+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+52023+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1575726250; cv=none; d=zohomail.com; s=zohoarc; b=Kk58vabxDx5LG4FpqmF3f+oVcTXzqTXtbQ8Min+QYqfOn7Raw8C+qrwmXvytIUJN8TA90bprHD1vH7Dxq9uadiC9tzQbmIMAmlQxWH/peMo+h41+pA6A2BJCEz1cDIgAijqh7ZWKtcABjWZrRSB1PQLP/o3OcI1V4oyziCdtcho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575726250; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=ZfauaoPYc2CbLsX38wjTnxuzMs3D1y6uJkK6GW35C4A=; b=ieJnZwLEO4EQ3e9yL+Is9aQvPYm+66Yb6VhEvThR63bflC8A9XhdyhfF8c7uZCnRO3tkXNsmS6TEmzm0Uinr+AeaQFoP7DfZghwhuSjuHIh1t8ulwU8Uo0fkP1z2zgHjbMirOR23gPKGjQyiJhU9EzTW1sF6ctAAsATLxCQKH5A= 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+52023+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 1575726250380205.28832654704388; Sat, 7 Dec 2019 05:44:10 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 3mm2YY1788612xSMLWRXnHz5; Sat, 07 Dec 2019 05:44:09 -0800 X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.1513.1575726248791302932 for ; Sat, 07 Dec 2019 05:44:09 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Dec 2019 05:44:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,288,1571727600"; d="scan'208";a="224300667" X-Received: from jyao1-mobl2.ccr.corp.intel.com ([10.254.209.160]) by orsmga002.jf.intel.com with ESMTP; 07 Dec 2019 05:44:07 -0800 From: "Yao, Jiewen" To: devel@edk2.groups.io Cc: Jian J Wang , Chao Zhang , Jiewen Yao Subject: [edk2-devel] [PATCH] SecurityPkg/Tcg2Smm: Measure the table before patch. Date: Sat, 7 Dec 2019 21:43:56 +0800 Message-Id: <20191207134356.2412-1-jiewen.yao@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,jiewen.yao@intel.com X-Gm-Message-State: tmSCGEU2eDHUqByPjcDNDOAmx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1575726249; bh=EiBZI3V0nFIHTRsZIdtIpPww+42JU8xNA909YYjOLhk=; h=Cc:Date:From:Reply-To:Subject:To; b=BXzGQDeRnlcwm5QEgFlE0lkUxLwgCc/cYW+Debbkfh3D56iHSHyNUegEPyVNeWXrQCO TqTKnL2ds48dQYGpBfxv4ig/9PynQTGPZAaY08163gzjcWxHz0b1pM00UWr4NnsbRU1vo rEIq8fzKOjNpgQyNajOde3eMNUeGqZ0xTpU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1940 According to TCG PFP specification: the ACPI table must be measured prior to 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 + // or the PCD configuration change. // TpmMeasureAndLogData( 0, @@ -678,6 +666,18 @@ PublishAcpiTable ( TableSize ); =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) + )); + // // 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 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: --=20 2.19.2.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 (#52023): https://edk2.groups.io/g/devel/message/52023 Mute This Topic: https://groups.io/mt/67626075/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-