public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zhang, Chao B" <chao.b.zhang@intel.com>
To: "Yao, Jiewen" <jiewen.yao@intel.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [Patch] SecurityPkg/Tpm12CommandLib: Always check response returnCode
Date: Tue, 24 Jan 2017 08:38:02 +0000	[thread overview]
Message-ID: <FF72C7E4248F3C4E9BDF19D4918E90F2494F8F71@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503A8E4C70@shsmsx102.ccr.corp.intel.com>

Reviewed-by : Chao Zhang <chao.b.zhang@intel.com>

-----Original Message-----
From: Yao, Jiewen 
Sent: Tuesday, January 24, 2017 4:20 PM
To: Kinney, Michael D <michael.d.kinney@intel.com>; edk2-devel@lists.01.org
Cc: Zhang, Chao B <chao.b.zhang@intel.com>
Subject: RE: [Patch] SecurityPkg/Tpm12CommandLib: Always check response returnCode

Reviewed-by: Jiewen.yao@intel.com

> -----Original Message-----
> From: Kinney, Michael D
> Sent: Wednesday, January 11, 2017 2:23 AM
> To: edk2-devel@lists.01.org
> Cc: Zhang, Chao B <chao.b.zhang@intel.com>; Yao, Jiewen 
> <jiewen.yao@intel.com>
> Subject: [Patch] SecurityPkg/Tpm12CommandLib: Always check response 
> returnCode
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=338
> 
> Update the Tpm12CommandLib to consistently check the returnCode field 
> of a response packet.  These checks are missing from the GetCapability 
> and SelfTest commands.  The functions Tpm12ContinueSelfTest(), 
> Tpm12GetCapabilityFlagPermanent(), and
> Tpm12GetCapabilityFlagVolatile() are updated to verify that the 
> response returnCode is not an error.
> 
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
> ---
>  SecurityPkg/Library/Tpm12CommandLib/Tpm12GetCapability.c | 12
> +++++++++++-
>  SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c      | 16
> ++++++++++++++--
>  2 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12GetCapability.c
> b/SecurityPkg/Library/Tpm12CommandLib/Tpm12GetCapability.c
> index c33746a..c6eb9e1 100644
> --- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12GetCapability.c
> +++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12GetCapability.c
> @@ -1,7 +1,7 @@
>  /** @file
>    Implement TPM1.2 Get Capabilities related commands.
> 
> -Copyright (c) 2016, Intel Corporation. All rights reserved. <BR>
> +Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved. 
> +<BR>
>  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 @@ -79,6 +79,11 @@ Tpm12GetCapabilityFlagPermanent (
>      return Status;
>    }
> 
> +  if (SwapBytes32 (Response.Hdr.returnCode) != TPM_SUCCESS) {
> +    DEBUG ((DEBUG_ERROR, "Tpm12GetCapabilityFlagPermanent: Response
> Code error! 0x%08x\r\n", SwapBytes32 (Response.Hdr.returnCode)));
> +    return EFI_DEVICE_ERROR;
> +  }
> +
>    ZeroMem (TpmPermanentFlags, sizeof (*TpmPermanentFlags));
>    CopyMem (TpmPermanentFlags, &Response.Flags, MIN (sizeof 
> (*TpmPermanentFlags), Response.ResponseSize));
> 
> @@ -120,6 +125,11 @@ Tpm12GetCapabilityFlagVolatile (
>      return Status;
>    }
> 
> +  if (SwapBytes32 (Response.Hdr.returnCode) != TPM_SUCCESS) {
> +    DEBUG ((DEBUG_ERROR, "Tpm12GetCapabilityFlagVolatile: Response 
> + Code
> error! 0x%08x\r\n", SwapBytes32 (Response.Hdr.returnCode)));
> +    return EFI_DEVICE_ERROR;
> +  }
> +
>    ZeroMem (VolatileFlags, sizeof (*VolatileFlags));
>    CopyMem (VolatileFlags, &Response.Flags, MIN (sizeof 
> (*VolatileFlags), Response.ResponseSize));
> 
> diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
> b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
> index 8e232ee..579fed7 100644
> --- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
> +++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12SelfTest.c
> @@ -1,7 +1,7 @@
>  /** @file
>    Implement TPM1.2 NV Self Test related commands.
> 
> -Copyright (c) 2016, Intel Corporation. All rights reserved. <BR>
> +Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved. 
> +<BR>
>  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>  
> This program and the accompanying materials  are licensed and made 
> available under the terms and conditions of the BSD License @@ -16,6 
> +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
> EXPRESS OR IMPLIED.
>  #include <PiPei.h>
>  #include <Library/Tpm12CommandLib.h>
>  #include <Library/BaseLib.h>
> +#include <Library/DebugLib.h>
>  #include <Library/Tpm12DeviceLib.h>
> 
>  /**
> @@ -33,6 +34,7 @@ Tpm12ContinueSelfTest (
>    VOID
>    )
>  {
> +  EFI_STATUS           Status;
>    TPM_RQU_COMMAND_HDR  Command;
>    TPM_RSP_COMMAND_HDR  Response;
>    UINT32               Length;
> @@ -44,5 +46,15 @@ Tpm12ContinueSelfTest (
>    Command.paramSize = SwapBytes32 (sizeof (Command));
>    Command.ordinal   = SwapBytes32 (TPM_ORD_ContinueSelfTest);
>    Length = sizeof (Response);
> -  return Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, 
> &Length, (UINT8 *)&Response);
> +  Status = Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command,
> &Length, (UINT8 *)&Response);
> +  if (EFI_ERROR (Status)) {
> +    return Status;
> +  }
> +
> +  if (SwapBytes32 (Response.returnCode) != TPM_SUCCESS) {
> +    DEBUG ((DEBUG_ERROR, "Tpm12ContinueSelfTest: Response Code error!
> 0x%08x\r\n", SwapBytes32 (Response.returnCode)));
> +    return EFI_DEVICE_ERROR;
> +  }
> +
> +  return Status;
>  }
> --
> 2.6.3.windows.1



      reply	other threads:[~2017-01-24  8:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-10 18:22 [Patch] SecurityPkg/Tpm12CommandLib: Always check response returnCode Michael Kinney
2017-01-24  8:19 ` Yao, Jiewen
2017-01-24  8:38   ` Zhang, Chao B [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=FF72C7E4248F3C4E9BDF19D4918E90F2494F8F71@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