public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yao, Jiewen" <jiewen.yao@intel.com>
To: "Gao, Zhichao" <zhichao.gao@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Wang, Jian J" <jian.j.wang@intel.com>,
	"Zhang, Chao B" <chao.b.zhang@intel.com>
Subject: Re: [PATCH] SecurityPkg/TcgPhysicalPresenceLib: Replace the ASSERT with error code
Date: Fri, 17 Jan 2020 10:56:51 +0000	[thread overview]
Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503F8E506E@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20200117080928.6780-2-zhichao.gao@intel.com>

Reviewed-by: jiewen.yao@intel.com

> -----Original Message-----
> From: Gao, Zhichao <zhichao.gao@intel.com>
> Sent: Friday, January 17, 2020 4:09 PM
> To: devel@edk2.groups.io
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>;
> Zhang, Chao B <chao.b.zhang@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@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Signed-off-by: Zhichao Gao <zhichao.gao@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


      reply	other threads:[~2020-01-17 10:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-17  8:09 [PATCH] SecurityPkg/TcgPhysicalPresenceLib: Fix the operation of 11 Gao, Zhichao
2020-01-17  8:09 ` [PATCH] SecurityPkg/TcgPhysicalPresenceLib: Replace the ASSERT with error code Gao, Zhichao
2020-01-17 10:56   ` Yao, Jiewen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=74D8A39837DF1E4DA445A8C0B3885C503F8E506E@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox