From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 3A60181E1F for ; Mon, 21 Nov 2016 16:53:04 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP; 21 Nov 2016 16:53:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,678,1473145200"; d="scan'208";a="1062568729" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga001.jf.intel.com with ESMTP; 21 Nov 2016 16:53:03 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 21 Nov 2016 16:53:03 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.239]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.239]) with mapi id 14.03.0248.002; Tue, 22 Nov 2016 08:53:01 +0800 From: "Zhang, Chao B" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" Thread-Topic: [PATCH] SecurityPkg DxeTcg2PPLib: Lock Tcg2PhysicalPresenceFlags variable on S4 Thread-Index: AQHSQXGOTwhRE5p0P0OglRQtKiscHKDkMpZw Date: Tue, 22 Nov 2016 00:53:00 +0000 Message-ID: References: <1479455897-67200-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1479455897-67200-1-git-send-email-star.zeng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjgzOTA5MGQtN2FkNS00N2MyLTkyMGMtMjAyYzdmYmEwNzRhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkhOQUlSdFdyZytUMjhQUnZPUHhsN2k0d3lwTm9vaHNLT3FKVjJYc25HUnc9In0= x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] SecurityPkg DxeTcg2PPLib: Lock Tcg2PhysicalPresenceFlags variable on S4 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Nov 2016 00:53:04 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Chao Zhang Thanks & Best regards Chao Zhang -----Original Message----- From: Zeng, Star=20 Sent: Friday, November 18, 2016 3:58 PM To: edk2-devel@lists.01.org Cc: Zeng, Star; Yao, Jiewen; Zhang, Chao B Subject: [PATCH] SecurityPkg DxeTcg2PPLib: Lock Tcg2PhysicalPresenceFlags v= ariable on S4 The code updates Tcg2PhysicalPresenceLibProcessRequest() to also lock Tcg2PhysicalPresenceFlags variable on S4. Cc: Jiewen Yao Cc: Chao Zhang Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng --- .../DxeTcg2PhysicalPresenceLib.c | 34 +++++++++++-------= ---- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2Physical= PresenceLib.c b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2Physi= calPresenceLib.c index 4cec0f75278b..bfecffa0fed8 100644 --- a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenc= eLib.c +++ b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenc= eLib.c @@ -794,6 +794,23 @@ Tcg2PhysicalPresenceLibProcessRequest ( if (EFI_ERROR (Status)) { return ; } + + // + // This flags variable controls whether physical presence is required fo= r TPM command.=20 + // It should be protected from malicious software. We set it as read-onl= y variable here. + // + Status =3D gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (= VOID **)&VariableLockProtocol); + if (!EFI_ERROR (Status)) { + Status =3D VariableLockProtocol->RequestToLock ( + VariableLockProtocol, + TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE= , + &gEfiTcg2PhysicalPresenceGuid + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "[TPM2] Error when lock variable %s, Status =3D= %r\n", TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE, Status)); + ASSERT_EFI_ERROR (Status); + } + } =20 // // Check S4 resume @@ -832,23 +849,6 @@ Tcg2PhysicalPresenceLibProcessRequest ( } } DEBUG ((EFI_D_INFO, "[TPM2] PpiFlags =3D %x\n", PpiFlags.PPFlags)); - - // - // This flags variable controls whether physical presence is required fo= r TPM command.=20 - // It should be protected from malicious software. We set it as read-onl= y variable here. - // - Status =3D gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (= VOID **)&VariableLockProtocol); - if (!EFI_ERROR (Status)) { - Status =3D VariableLockProtocol->RequestToLock ( - VariableLockProtocol, - TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE= , - &gEfiTcg2PhysicalPresenceGuid - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "[TPM2] Error when lock variable %s, Status =3D= %r\n", TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE, Status)); - ASSERT_EFI_ERROR (Status); - } - } =20 // // Initialize physical presence variable. --=20 2.7.0.windows.1