From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web10.4961.1579258614565984045 for ; Fri, 17 Jan 2020 02:56:54 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: jiewen.yao@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 fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jan 2020 02:56:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,329,1574150400"; d="scan'208";a="424426005" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga005.fm.intel.com with ESMTP; 17 Jan 2020 02:56:54 -0800 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 17 Jan 2020 02:56:53 -0800 Received: from shsmsx107.ccr.corp.intel.com (10.239.4.96) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 17 Jan 2020 02:56:53 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.202]) by SHSMSX107.ccr.corp.intel.com ([169.254.9.210]) with mapi id 14.03.0439.000; Fri, 17 Jan 2020 18:56:52 +0800 From: "Yao, Jiewen" To: "Gao, Zhichao" , "devel@edk2.groups.io" CC: "Wang, Jian J" , "Zhang, Chao B" Subject: Re: [PATCH] SecurityPkg/TcgPhysicalPresenceLib: Replace the ASSERT with error code Thread-Topic: [PATCH] SecurityPkg/TcgPhysicalPresenceLib: Replace the ASSERT with error code Thread-Index: AQHVzQ165gJqqPh0ykq44l8/c+EH/Kfur3QA Date: Fri, 17 Jan 2020 10:56:51 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503F8E506E@shsmsx102.ccr.corp.intel.com> References: <20200117080928.6780-1-zhichao.gao@intel.com> <20200117080928.6780-2-zhichao.gao@intel.com> In-Reply-To: <20200117080928.6780-2-zhichao.gao@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTYzYWZmYzUtMmQwMy00OTljLWJmYTMtYzA2OGExNzVhZDYwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiYnB4dmhCeDBxTzNwYmNTdXZ0WWk3VUVITWNcL0pYVkh1bU5DOEJheDFHUGViUWluZlhFYzJvMzVxbDF1cUFZTGsifQ== x-ctpclassification: CTP_NT 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: jiewen.yao@intel.com 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: Gao, Zhichao > Sent: Friday, January 17, 2020 4:09 PM > To: devel@edk2.groups.io > Cc: Yao, Jiewen ; Wang, Jian J ; > Zhang, Chao B > Subject: [PATCH] SecurityPkg/TcgPhysicalPresenceLib: Replace the ASSERT w= ith > error code >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2472 >=20 > Replace the ASSERT with the error code return in the TpmPhysicalPresence > and GetTpmCapability. > Add missing error checking after call TpmPhysicalPresence in > TcgPhysicalPresenceLibProcessRequest. >=20 > Cc: Jiewen Yao > Cc: Jian J Wang > Cc: Chao Zhang > Signed-off-by: Zhichao Gao > --- > SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.= c | > 23 +++++++++++++++----- > 1 file changed, 18 insertions(+), 5 deletions(-) >=20 > diff --git > a/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib= .c > b/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib= .c > index bc0b2e0677..ee7aa5d052 100644 > --- > a/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib= .c > +++ > b/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib= .c > @@ -102,9 +102,13 @@ GetTpmCapability ( > sizeof (RecvBuffer), > (UINT8*)&RecvBuffer > ); > - ASSERT_EFI_ERROR (Status); > - ASSERT (TpmRsp->tag =3D=3D SwapBytes16 (TPM_TAG_RSP_COMMAND)); > - ASSERT (TpmRsp->returnCode =3D=3D 0); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + if ((TpmRsp->tag !=3D SwapBytes16 (TPM_TAG_RSP_COMMAND)) || (TpmRsp- > >returnCode !=3D 0)) { > + return EFI_DEVICE_ERROR; > + } >=20 > TpmPermanentFlags =3D (TPM_PERMANENT_FLAGS *)&RecvBuffer[sizeof > (TPM_RSP_COMMAND_HDR) + sizeof (UINT32)]; >=20 > @@ -157,8 +161,14 @@ TpmPhysicalPresence ( > sizeof (TpmRsp), > (UINT8*)&TpmRsp > ); > - ASSERT_EFI_ERROR (Status); > - ASSERT (TpmRsp.tag =3D=3D SwapBytes16 (TPM_TAG_RSP_COMMAND)); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + if (TpmRsp.tag !=3D SwapBytes16 (TPM_TAG_RSP_COMMAND)) { > + return EFI_DEVICE_ERROR; > + } > + > if (TpmRsp.returnCode !=3D 0) { > // > // If it fails, some requirements may be needed for this command. > @@ -1282,6 +1292,9 @@ TcgPhysicalPresenceLibProcessRequest ( > // Set operator physical presence flags > // > TpmPhysicalPresence (TcgProtocol, TPM_PHYSICAL_PRESENCE_PRESENT); > + if (EFI_ERROR (Status)) { > + return; > + } >=20 > // > // Execute pending TPM request. > -- > 2.21.0.windows.1