public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 0/1] SecurityPkg: Fix incorrect return value when File is NULL
@ 2020-02-07  0:04 Philippe Mathieu-Daudé
  2020-02-07  0:04 ` [PATCH v2 1/1] " Philippe Mathieu-Daudé
  0 siblings, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-07  0:04 UTC (permalink / raw)
  To: devel; +Cc: Philippe Mathieu-Daude

Since v1: https://edk2.groups.io/g/devel/message/53741
- Addressed Jian Wang review comment.

Since there is a logical change, I'm not adding Laszlo's
Acked-by from v1.

Philippe Mathieu-Daudé (1):
  SecurityPkg: Fix incorrect return value when File is NULL

 .../DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c        | 9 ++++++++-
 .../Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c  | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

-- 
2.21.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/1] SecurityPkg: Fix incorrect return value when File is NULL
  2020-02-07  0:04 [PATCH v2 0/1] SecurityPkg: Fix incorrect return value when File is NULL Philippe Mathieu-Daudé
@ 2020-02-07  0:04 ` Philippe Mathieu-Daudé
  2020-02-07 11:37   ` [edk2-devel] " Laszlo Ersek
  2020-02-10  6:34   ` Wang, Jian J
  0 siblings, 2 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-07  0:04 UTC (permalink / raw)
  To: devel; +Cc: Philippe Mathieu-Daude, Jiewen Yao, Jian J Wang, Chao Zhang

The DxeTpmMeasureBootHandler and DxeTpm2MeasureBootHandler handlers
are SECURITY2_FILE_AUTHENTICATION_HANDLER prototype. This prototype
can not return EFI_INVALID_PARAMETER.

The prototype documentation states it returns EFI_ACCESS_DENIED if:

  "The file specified by File and FileBuffer did not authenticate,
   and the platform policy dictates that the DXE Foundation may not
   use File."

Correct the documentation, and add a early check, returning
EFI_ACCESS_DENIED when File is NULL.

Noticed while reviewing commit 6d57592740cdd0b6868baeef7929d6e6fef.

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: Philippe Mathieu-Daude <philmd@redhat.com>
---
 .../DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c        | 9 ++++++++-
 .../Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c  | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
index 04b9b0d7fbf3..cabc0c6c7556 100644
--- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
@@ -384,7 +384,7 @@ Tcg2MeasurePeImage (
   and other exception operations.  The File parameter allows for possible logging
   within the SAP of the driver.
 
-  If File is NULL, then EFI_INVALID_PARAMETER is returned.
+  If File is NULL, then EFI_ACCESS_DENIED is returned.
 
   If the file specified by File with an authentication status specified by
   AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.
@@ -435,6 +435,13 @@ DxeTpm2MeasureBootHandler (
   EFI_PHYSICAL_ADDRESS                FvAddress;
   UINT32                              Index;
 
+  //
+  // Check for invalid parameters.
+  //
+  if (File == NULL) {
+    return EFI_ACCESS_DENIED;
+  }
+
   Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **) &Tcg2Protocol);
   if (EFI_ERROR (Status)) {
     //
diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
index 1f2eed29a1df..dfaaa0f0b332 100644
--- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
@@ -678,7 +678,7 @@ TcgMeasurePeImage (
   and other exception operations.  The File parameter allows for possible logging
   within the SAP of the driver.
 
-  If File is NULL, then EFI_INVALID_PARAMETER is returned.
+  If File is NULL, then EFI_ACCESS_DENIED is returned.
 
   If the file specified by File with an authentication status specified by
   AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.
@@ -732,6 +732,13 @@ DxeTpmMeasureBootHandler (
   EFI_PHYSICAL_ADDRESS                FvAddress;
   UINT32                              Index;
 
+  //
+  // Check for invalid parameters.
+  //
+  if (File == NULL) {
+    return EFI_ACCESS_DENIED;
+  }
+
   Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **) &TcgProtocol);
   if (EFI_ERROR (Status)) {
     //
-- 
2.21.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH v2 1/1] SecurityPkg: Fix incorrect return value when File is NULL
  2020-02-07  0:04 ` [PATCH v2 1/1] " Philippe Mathieu-Daudé
@ 2020-02-07 11:37   ` Laszlo Ersek
  2020-02-10  6:34   ` Wang, Jian J
  1 sibling, 0 replies; 4+ messages in thread
From: Laszlo Ersek @ 2020-02-07 11:37 UTC (permalink / raw)
  To: devel, philmd; +Cc: Jiewen Yao, Jian J Wang, Chao Zhang

On 02/07/20 01:04, Philippe Mathieu-Daudé wrote:
> The DxeTpmMeasureBootHandler and DxeTpm2MeasureBootHandler handlers
> are SECURITY2_FILE_AUTHENTICATION_HANDLER prototype. This prototype
> can not return EFI_INVALID_PARAMETER.
> 
> The prototype documentation states it returns EFI_ACCESS_DENIED if:
> 
>   "The file specified by File and FileBuffer did not authenticate,
>    and the platform policy dictates that the DXE Foundation may not
>    use File."
> 
> Correct the documentation, and add a early check, returning
> EFI_ACCESS_DENIED when File is NULL.
> 
> Noticed while reviewing commit 6d57592740cdd0b6868baeef7929d6e6fef.
> 
> 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: Philippe Mathieu-Daude <philmd@redhat.com>
> ---
>  .../DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c        | 9 ++++++++-
>  .../Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c  | 9 ++++++++-
>  2 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
> index 04b9b0d7fbf3..cabc0c6c7556 100644
> --- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
> +++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
> @@ -384,7 +384,7 @@ Tcg2MeasurePeImage (
>    and other exception operations.  The File parameter allows for possible logging
>    within the SAP of the driver.
>  
> -  If File is NULL, then EFI_INVALID_PARAMETER is returned.
> +  If File is NULL, then EFI_ACCESS_DENIED is returned.
>  
>    If the file specified by File with an authentication status specified by
>    AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.
> @@ -435,6 +435,13 @@ DxeTpm2MeasureBootHandler (
>    EFI_PHYSICAL_ADDRESS                FvAddress;
>    UINT32                              Index;
>  
> +  //
> +  // Check for invalid parameters.
> +  //
> +  if (File == NULL) {
> +    return EFI_ACCESS_DENIED;
> +  }
> +
>    Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **) &Tcg2Protocol);
>    if (EFI_ERROR (Status)) {
>      //
> diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
> index 1f2eed29a1df..dfaaa0f0b332 100644
> --- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
> +++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
> @@ -678,7 +678,7 @@ TcgMeasurePeImage (
>    and other exception operations.  The File parameter allows for possible logging
>    within the SAP of the driver.
>  
> -  If File is NULL, then EFI_INVALID_PARAMETER is returned.
> +  If File is NULL, then EFI_ACCESS_DENIED is returned.
>  
>    If the file specified by File with an authentication status specified by
>    AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.
> @@ -732,6 +732,13 @@ DxeTpmMeasureBootHandler (
>    EFI_PHYSICAL_ADDRESS                FvAddress;
>    UINT32                              Index;
>  
> +  //
> +  // Check for invalid parameters.
> +  //
> +  if (File == NULL) {
> +    return EFI_ACCESS_DENIED;
> +  }
> +
>    Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **) &TcgProtocol);
>    if (EFI_ERROR (Status)) {
>      //
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [PATCH v2 1/1] SecurityPkg: Fix incorrect return value when File is NULL
  2020-02-07  0:04 ` [PATCH v2 1/1] " Philippe Mathieu-Daudé
  2020-02-07 11:37   ` [edk2-devel] " Laszlo Ersek
@ 2020-02-10  6:34   ` Wang, Jian J
  1 sibling, 0 replies; 4+ messages in thread
From: Wang, Jian J @ 2020-02-10  6:34 UTC (permalink / raw)
  To: devel@edk2.groups.io, philmd@redhat.com; +Cc: Yao, Jiewen, Zhang, Chao B


Reviewed-by: Jian J Wang <jian.j.wang@intel.com>

Regards,
Jian

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Philippe
> Mathieu-Daudé
> Sent: Friday, February 07, 2020 8:05 AM
> To: devel@edk2.groups.io
> Cc: Philippe Mathieu-Daude <philmd@redhat.com>; Yao, Jiewen
> <jiewen.yao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Zhang, Chao B
> <chao.b.zhang@intel.com>
> Subject: [edk2-devel] [PATCH v2 1/1] SecurityPkg: Fix incorrect return value
> when File is NULL
> 
> The DxeTpmMeasureBootHandler and DxeTpm2MeasureBootHandler handlers
> are SECURITY2_FILE_AUTHENTICATION_HANDLER prototype. This prototype
> can not return EFI_INVALID_PARAMETER.
> 
> The prototype documentation states it returns EFI_ACCESS_DENIED if:
> 
>   "The file specified by File and FileBuffer did not authenticate,
>    and the platform policy dictates that the DXE Foundation may not
>    use File."
> 
> Correct the documentation, and add a early check, returning
> EFI_ACCESS_DENIED when File is NULL.
> 
> Noticed while reviewing commit 6d57592740cdd0b6868baeef7929d6e6fef.
> 
> 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: Philippe Mathieu-Daude <philmd@redhat.com>
> ---
>  .../DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c        | 9 ++++++++-
>  .../Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c  | 9 ++++++++-
>  2 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git
> a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
> b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
> index 04b9b0d7fbf3..cabc0c6c7556 100644
> --- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
> +++
> b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
> @@ -384,7 +384,7 @@ Tcg2MeasurePeImage (
>    and other exception operations.  The File parameter allows for possible
> logging
>    within the SAP of the driver.
> 
> -  If File is NULL, then EFI_INVALID_PARAMETER is returned.
> +  If File is NULL, then EFI_ACCESS_DENIED is returned.
> 
>    If the file specified by File with an authentication status specified by
>    AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is
> returned.
> @@ -435,6 +435,13 @@ DxeTpm2MeasureBootHandler (
>    EFI_PHYSICAL_ADDRESS                FvAddress;
>    UINT32                              Index;
> 
> +  //
> +  // Check for invalid parameters.
> +  //
> +  if (File == NULL) {
> +    return EFI_ACCESS_DENIED;
> +  }
> +
>    Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **)
> &Tcg2Protocol);
>    if (EFI_ERROR (Status)) {
>      //
> diff --git
> a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
> b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
> index 1f2eed29a1df..dfaaa0f0b332 100644
> --- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
> +++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
> @@ -678,7 +678,7 @@ TcgMeasurePeImage (
>    and other exception operations.  The File parameter allows for possible
> logging
>    within the SAP of the driver.
> 
> -  If File is NULL, then EFI_INVALID_PARAMETER is returned.
> +  If File is NULL, then EFI_ACCESS_DENIED is returned.
> 
>    If the file specified by File with an authentication status specified by
>    AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is
> returned.
> @@ -732,6 +732,13 @@ DxeTpmMeasureBootHandler (
>    EFI_PHYSICAL_ADDRESS                FvAddress;
>    UINT32                              Index;
> 
> +  //
> +  // Check for invalid parameters.
> +  //
> +  if (File == NULL) {
> +    return EFI_ACCESS_DENIED;
> +  }
> +
>    Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **)
> &TcgProtocol);
>    if (EFI_ERROR (Status)) {
>      //
> --
> 2.21.1
> 
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-10  6:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-07  0:04 [PATCH v2 0/1] SecurityPkg: Fix incorrect return value when File is NULL Philippe Mathieu-Daudé
2020-02-07  0:04 ` [PATCH v2 1/1] " Philippe Mathieu-Daudé
2020-02-07 11:37   ` [edk2-devel] " Laszlo Ersek
2020-02-10  6:34   ` Wang, Jian J

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox