From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 693AE21F0DA45 for ; Mon, 5 Feb 2018 18:27:52 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2018 18:33:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,467,1511856000"; d="scan'208";a="171962190" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 05 Feb 2018 18:33:34 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 5 Feb 2018 18:33:32 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.253]) with mapi id 14.03.0319.002; Tue, 6 Feb 2018 10:33:30 +0800 From: "Yao, Jiewen" To: "Long, Qin" , "Zhang, Chao B" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] SecurityPkg: Support PP version lower than 1.3 Thread-Index: AQHTnimOmz2Dulw5tkSV8netm7WPHqOWIkaAgACHBJA= Date: Tue, 6 Feb 2018 02:33:29 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AAB5859@shsmsx102.ccr.corp.intel.com> References: <20180205023217.20904-1-chao.b.zhang@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOWNiNzNmMDgtYjU5ZS00NWUyLWFmM2UtMjg5NmU4Y2MzOWIzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJzVXVzTm8xMVBkUHFsbG9yNU05SkprK2tpYklUVU5maXpvMzh4djZMcVh6QTNEcWxxU1V6a0JXUlk4cUw4THFYIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] SecurityPkg: Support PP version lower than 1.3 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 02:27:52 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Yeah. I suggest we just use sizeof() for the fixed string. > -----Original Message----- > From: Long, Qin > Sent: Tuesday, February 6, 2018 10:30 AM > To: Zhang, Chao B ; edk2-devel@lists.01.org > Cc: Yao, Jiewen > Subject: RE: [PATCH] SecurityPkg: Support PP version lower than 1.3 >=20 > Could you update the AsciiStrLen usage with safe version, or direct "size= of()"? > Others looks good to me. >=20 > Reviewed-by: Long Qin >=20 >=20 > Best Regards & Thanks, > LONG, Qin >=20 > -----Original Message----- > From: Zhang, Chao B > Sent: Monday, February 5, 2018 10:32 AM > To: edk2-devel@lists.01.org > Cc: Long, Qin ; Yao, Jiewen ; > Zhang, Chao B > Subject: [PATCH] SecurityPkg: Support PP version lower than 1.3 >=20 > TCG PP 1.2 & PP 1.3 spec defined different Opcodes. > Update code to support both. >=20 > Cc: Long Qin > Cc: Yao Jiewen > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Chao Zhang > --- > .../SmmTcg2PhysicalPresenceLib.c | 31 > +++++++++++++++++----- > .../SmmTcg2PhysicalPresenceLib.inf | 7 +++-- > 2 files changed, 30 insertions(+), 8 deletions(-) >=20 > diff --git > a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresence > Lib.c > b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresence > Lib.c > index 6061453..ffade10 100644 > --- > a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresence > Lib.c > +++ b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPres > +++ enceLib.c > @@ -10,7 +10,7 @@ > Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction() and > Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction() > will receive untrusted input and do validation. >=20 > -Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at @@ > -27,12 +27,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, > EITHER EXPRESS OR IMPLIED. >=20 > #include >=20 > +#include > #include > #include > #include > #include >=20 > +#define PP_INF_VERSION_1_2 "1.2" > + > EFI_SMM_VARIABLE_PROTOCOL *mTcg2PpSmmVariable; > +BOOLEAN mIsTcg2PPVerLowerThan_1_3 =3D FALSE; >=20 > /** > The handler for TPM physical presence function: > @@ -337,11 +341,22 @@ > Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction ( > break; >=20 > default: > - if (OperationRequest < > TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) { > - // > - // TCG PP spec defined operations that are reserved or > un-implemented > - // > - return TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED; > + if (mIsTcg2PPVerLowerThan_1_3 =3D=3D FALSE) { > + if (OperationRequest < > TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) { > + // > + // TCG2 PP1.3 spec defined operations that are reserved or > un-implemented > + // > + return TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED; > + } > + } else { > + // > + // TCG PP lower than 1.3. (1.0, 1.1, 1.2) > + // > + if (OperationRequest <=3D > TCG2_PHYSICAL_PRESENCE_NO_ACTION_MAX) { > + RequestConfirmed =3D TRUE; > + } else if (OperationRequest < > TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) { > + return TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED; > + } > } > break; > } > @@ -377,6 +392,10 @@ Tcg2PhysicalPresenceLibConstructor ( { > EFI_STATUS Status; >=20 > + if (AsciiStrnCmp(PP_INF_VERSION_1_2, (CHAR8 > *)PcdGetPtr(PcdTcgPhysicalPresenceInterfaceVer), > AsciiStrLen(PP_INF_VERSION_1_2)) <=3D0) { > + mIsTcg2PPVerLowerThan_1_3 =3D TRUE; > + } > + > // > // Locate SmmVariableProtocol. > // > diff --git > a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresence > Lib.inf > b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresence > Lib.inf > index 5fa84b1..8367097 100644 > --- > a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresence > Lib.inf > +++ b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPres > +++ enceLib.inf > @@ -7,7 +7,7 @@ > # This driver will have external input - variable. > # This external input must be validated carefully to avoid security iss= ue. > # > -# Copyright (c) 2015, Intel Corporation. All rights reserved.
> +# Copyright (c) 2015 - 2018, Intel Corporation. All rights > +reserved.
> # This program and the accompanying materials # are licensed and made > available under the terms and conditions of the BSD License # which > accompanies this distribution. The full text of the license may be found = at @@ > -52,6 +52,9 @@ > ## SOMETIMES_CONSUMES ## Variable:L"PhysicalPresence" > ## SOMETIMES_CONSUMES ## Variable:L"PhysicalPresenceFlags" > gEfiTcg2PhysicalPresenceGuid > - > + > +[Pcd] > + gEfiSecurityPkgTokenSpaceGuid.PcdTcgPhysicalPresenceInterfaceVer ## > +CONSUMES > + > [Depex] > gEfiSmmVariableProtocolGuid > \ No newline at end of file > -- > 1.9.5.msysgit.1