[edk2-devel] [PATCH] SecurityPkg/TcgPhysicalPresenceLib: Replace the ASSERT with error code
Yao, Jiewen
jiewen.yao at intel.com
Fri Jan 17 10:56:51 UTC 2020
Reviewed-by: jiewen.yao at intel.com
> -----Original Message-----
> From: Gao, Zhichao <zhichao.gao at intel.com>
> Sent: Friday, January 17, 2020 4:09 PM
> To: devel at edk2.groups.io
> Cc: Yao, Jiewen <jiewen.yao at intel.com>; Wang, Jian J <jian.j.wang at intel.com>;
> Zhang, Chao B <chao.b.zhang at intel.com>
> Subject: [PATCH] SecurityPkg/TcgPhysicalPresenceLib: Replace the ASSERT with
> error code
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2472
>
> Replace the ASSERT with the error code return in the TpmPhysicalPresence
> and GetTpmCapability.
> Add missing error checking after call TpmPhysicalPresence in
> TcgPhysicalPresenceLibProcessRequest.
>
> Cc: Jiewen Yao <jiewen.yao at intel.com>
> Cc: Jian J Wang <jian.j.wang at intel.com>
> Cc: Chao Zhang <chao.b.zhang at intel.com>
> Signed-off-by: Zhichao Gao <zhichao.gao at intel.com>
> ---
> SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c |
> 23 +++++++++++++++-----
> 1 file changed, 18 insertions(+), 5 deletions(-)
>
> 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 == SwapBytes16 (TPM_TAG_RSP_COMMAND));
> - ASSERT (TpmRsp->returnCode == 0);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + if ((TpmRsp->tag != SwapBytes16 (TPM_TAG_RSP_COMMAND)) || (TpmRsp-
> >returnCode != 0)) {
> + return EFI_DEVICE_ERROR;
> + }
>
> TpmPermanentFlags = (TPM_PERMANENT_FLAGS *)&RecvBuffer[sizeof
> (TPM_RSP_COMMAND_HDR) + sizeof (UINT32)];
>
> @@ -157,8 +161,14 @@ TpmPhysicalPresence (
> sizeof (TpmRsp),
> (UINT8*)&TpmRsp
> );
> - ASSERT_EFI_ERROR (Status);
> - ASSERT (TpmRsp.tag == SwapBytes16 (TPM_TAG_RSP_COMMAND));
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + if (TpmRsp.tag != SwapBytes16 (TPM_TAG_RSP_COMMAND)) {
> + return EFI_DEVICE_ERROR;
> + }
> +
> if (TpmRsp.returnCode != 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;
> + }
>
> //
> // Execute pending TPM request.
> --
> 2.21.0.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#53357): https://edk2.groups.io/g/devel/message/53357
Mute This Topic: https://groups.io/mt/69839556/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list