From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 321501A1E04 for ; Tue, 30 Aug 2016 18:59:42 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP; 30 Aug 2016 18:59:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,260,1470726000"; d="scan'208";a="3180599" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga004.jf.intel.com with ESMTP; 30 Aug 2016 18:59:40 -0700 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 30 Aug 2016 18:59:40 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 30 Aug 2016 18:59:39 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.109]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.91]) with mapi id 14.03.0248.002; Wed, 31 Aug 2016 09:59:37 +0800 From: "Yao, Jiewen" To: "Zhang, Chao B" , "edk2-devel@lists.01.org" CC: "Long, Qin" Thread-Topic: [PATCH] SecurityPkg: TPM12CommandLib: Add Response returnCode Check Thread-Index: AQHSAymJrNSPtZoqbE+6yZApVM3Mq6BiUEag Date: Wed, 31 Aug 2016 01:59:37 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C50385F6041@shsmsx102.ccr.corp.intel.com> References: <1472607998-21964-1-git-send-email-chao.b.zhang@intel.com> In-Reply-To: <1472607998-21964-1-git-send-email-chao.b.zhang@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] SecurityPkg: TPM12CommandLib: Add Response returnCode Check 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: Wed, 31 Aug 2016 01:59:42 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Zhang, Chao B > Sent: Wednesday, August 31, 2016 9:47 AM > To: edk2-devel@lists.01.org > Cc: Long, Qin ; Yao, Jiewen ; > Zhang, Chao B > Subject: [PATCH] SecurityPkg: TPM12CommandLib: Add Response > returnCode Check >=20 > Check response return code before return from Tpm12Extend and > Tpm12PhysicalPresence. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Chao Zhang > --- > SecurityPkg/Library/Tpm12CommandLib/Tpm12Pcr.c | 5 > +++++ > .../Library/Tpm12CommandLib/Tpm12PhysicalPresence.c | 14 > +++++++++++++- > 2 files changed, 18 insertions(+), 1 deletion(-) >=20 > diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12Pcr.c > b/SecurityPkg/Library/Tpm12CommandLib/Tpm12Pcr.c > index 321653f..18d5b96 100644 > --- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12Pcr.c > +++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12Pcr.c > @@ -74,6 +74,11 @@ Tpm12Extend ( > return Status; > } >=20 > + if (SwapBytes32(Response.Hdr.returnCode) !=3D TPM_SUCCESS) { > + DEBUG ((EFI_D_ERROR, "Tpm12Extend: Response Code error! > 0x%08x\r\n", SwapBytes32(Response.Hdr.returnCode))); > + return EFI_DEVICE_ERROR; > + } > + > if (NewPcrValue !=3D NULL) { > CopyMem (NewPcrValue, &Response.TpmDigest, sizeof > (*NewPcrValue)); > } > diff --git > a/SecurityPkg/Library/Tpm12CommandLib/Tpm12PhysicalPresence.c > b/SecurityPkg/Library/Tpm12CommandLib/Tpm12PhysicalPresence.c > index a730334..d8d1998 100644 > --- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12PhysicalPresence.c > +++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12PhysicalPresence.c > @@ -44,6 +44,7 @@ Tpm12PhysicalPresence ( > IN TPM_PHYSICAL_PRESENCE PhysicalPresence > ) > { > + EFI_STATUS Status; > TPM_CMD_PHYSICAL_PRESENCE Command; > TPM_RSP_COMMAND_HDR Response; > UINT32 Length; > @@ -56,5 +57,16 @@ Tpm12PhysicalPresence ( > Command.Hdr.ordinal =3D SwapBytes32 > (TSC_ORD_PhysicalPresence); > Command.PhysicalPresence =3D SwapBytes16 (PhysicalPresence); > Length =3D sizeof (Response); > - return Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, > &Length, (UINT8 *)&Response); > + > + Status =3D Tpm12SubmitCommand (sizeof (Command), (UINT8 > *)&Command, &Length, (UINT8 *)&Response); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + if (SwapBytes32(Response.returnCode) !=3D TPM_SUCCESS) { > + DEBUG ((EFI_D_ERROR, "Tpm12PhysicalPresence: Response Code > error! 0x%08x\r\n", SwapBytes32(Response.returnCode))); > + return EFI_DEVICE_ERROR; > + } > + > + return EFI_SUCCESS; > } > -- > 1.9.5.msysgit.1