]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg/TPM: measure UEFI images without associated device paths again
authorGuomin Jiang <guomin.jiang@intel.com>
Wed, 15 Apr 2020 03:33:08 +0000 (11:33 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 22 Apr 2020 01:55:34 +0000 (01:55 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2652

DxeTpm2MeasureBootHandler() and DxeTpmMeasureBootHandler() functions may
receive a FileBuffer argument that is not associated with any particular
device path (e.g., because the UEFI image has not been loaded from any
particular device path).
Therefore rejecting (File==NULL) at the top of the function is invalid.

Fixes: 4b026f0d5af36faf3a3629a3ad49c51b5b3be12f
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: Guomin Jiang <guomin.jiang@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c

index f0e95e5ec01e3d28e15ba15ba535e704824ae08b..92eac715800ff34fe9e9ff007d089eab7aa8699b 100644 (file)
@@ -384,8 +384,6 @@ Finish:
   and other exception operations.  The File parameter allows for possible logging\r
   within the SAP of the driver.\r
 \r
-  If File is NULL, then EFI_ACCESS_DENIED is returned.\r
-\r
   If the file specified by File with an authentication status specified by\r
   AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.\r
 \r
@@ -398,6 +396,8 @@ Finish:
   might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is\r
   returned.\r
 \r
+  If check image specified by FileBuffer and File is NULL meanwhile, return EFI_ACCESS_DENIED.\r
+\r
   @param[in]      AuthenticationStatus  This is the authentication status returned\r
                                         from the securitymeasurement services for the\r
                                         input file.\r
@@ -416,7 +416,7 @@ EFI_STATUS
 EFIAPI\r
 DxeTpm2MeasureBootHandler (\r
   IN  UINT32                           AuthenticationStatus,\r
-  IN  CONST EFI_DEVICE_PATH_PROTOCOL   *File,\r
+  IN  CONST EFI_DEVICE_PATH_PROTOCOL   *File, OPTIONAL\r
   IN  VOID                             *FileBuffer,\r
   IN  UINTN                            FileSize,\r
   IN  BOOLEAN                          BootPolicy\r
@@ -435,13 +435,6 @@ DxeTpm2MeasureBootHandler (
   EFI_PHYSICAL_ADDRESS                FvAddress;\r
   UINT32                              Index;\r
 \r
-  //\r
-  // Check for invalid parameters.\r
-  //\r
-  if (File == NULL) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-\r
   Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **) &Tcg2Protocol);\r
   if (EFI_ERROR (Status)) {\r
     //\r
@@ -615,6 +608,13 @@ DxeTpm2MeasureBootHandler (
   //\r
   Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
   if (EFI_ERROR (Status)) {\r
+    //\r
+    // Check for invalid parameters.\r
+    //\r
+    if (File == NULL) {\r
+      Status = EFI_ACCESS_DENIED;\r
+    }\r
+\r
     //\r
     // The information can't be got from the invalid PeImage\r
     //\r
index d499371e7aec14fff732fb71b5724e9389768198..d990eb2ad3a9f8007cb49bb50075e2cfc9bcddc3 100644 (file)
@@ -678,8 +678,6 @@ Finish:
   and other exception operations.  The File parameter allows for possible logging\r
   within the SAP of the driver.\r
 \r
-  If File is NULL, then EFI_ACCESS_DENIED is returned.\r
-\r
   If the file specified by File with an authentication status specified by\r
   AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.\r
 \r
@@ -692,6 +690,8 @@ Finish:
   might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is\r
   returned.\r
 \r
+  If check image specified by FileBuffer and File is NULL meanwhile, return EFI_ACCESS_DENIED.\r
+\r
   @param[in]      AuthenticationStatus  This is the authentication status returned\r
                                         from the securitymeasurement services for the\r
                                         input file.\r
@@ -710,7 +710,7 @@ EFI_STATUS
 EFIAPI\r
 DxeTpmMeasureBootHandler (\r
   IN  UINT32                           AuthenticationStatus,\r
-  IN  CONST EFI_DEVICE_PATH_PROTOCOL   *File,\r
+  IN  CONST EFI_DEVICE_PATH_PROTOCOL   *File, OPTIONAL\r
   IN  VOID                             *FileBuffer,\r
   IN  UINTN                            FileSize,\r
   IN  BOOLEAN                          BootPolicy\r
@@ -732,13 +732,6 @@ DxeTpmMeasureBootHandler (
   EFI_PHYSICAL_ADDRESS                FvAddress;\r
   UINT32                              Index;\r
 \r
-  //\r
-  // Check for invalid parameters.\r
-  //\r
-  if (File == NULL) {\r
-    return EFI_ACCESS_DENIED;\r
-  }\r
-\r
   Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **) &TcgProtocol);\r
   if (EFI_ERROR (Status)) {\r
     //\r
@@ -912,6 +905,13 @@ DxeTpmMeasureBootHandler (
   //\r
   Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
   if (EFI_ERROR (Status)) {\r
+    //\r
+    // Check for invalid parameters.\r
+    //\r
+    if (File == NULL) {\r
+      return EFI_ACCESS_DENIED;\r
+    }\r
+\r
     //\r
     // The information can't be got from the invalid PeImage\r
     //\r