]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.c
MdeModulePkg/DxeNetLib: Fix an error in packet length counting.
[mirror_edk2.git] / MdeModulePkg / Library / DxeSecurityManagementLib / DxeSecurityManagementLib.c
index 9af05a4406cf30906630f28aa949c82ffb48cbf9..aa4d93b6f3a2c1ebf24401a3db613f2d7afd4b67 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides generic security measurement functions for DXE module.\r
 \r
-Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -13,10 +13,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 \r
 #include <PiDxe.h>\r
+#include <Protocol/LoadFile.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/DxeServicesLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/SecurityManagementLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
 \r
 #define SECURITY_HANDLER_TABLE_SIZE   0x10\r
 \r
@@ -58,6 +61,7 @@ SECURITY2_INFO *mSecurity2Table      = NULL;
 RETURN_STATUS\r
 EFIAPI\r
 ReallocateSecurityHandlerTable (\r
+  VOID\r
   )\r
 {\r
   //\r
@@ -102,7 +106,7 @@ CheckAuthenticationOperation (
   //\r
   // Make sure new auth operation can be recognized.\r
   //\r
-  ASSERT ((CheckAuthOperation & ~(EFI_AUTH_IMAGE_OPERATION_MASK | EFI_AUTH_OPERATION_IMAGE_REQUIRED)) == 0);\r
+  ASSERT ((CheckAuthOperation & ~(EFI_AUTH_IMAGE_OPERATION_MASK | EFI_AUTH_OPERATION_AUTHENTICATION_STATE | EFI_AUTH_OPERATION_IMAGE_REQUIRED)) == 0);\r
   \r
   //\r
   // When current operation includes measure image operation, \r
@@ -219,6 +223,9 @@ ExecuteSecurityHandlers (
   UINT32        HandlerAuthenticationStatus;\r
   VOID          *FileBuffer;\r
   UINTN         FileSize;\r
+  EFI_HANDLE    Handle;\r
+  EFI_DEVICE_PATH_PROTOCOL        *Node;\r
+  EFI_DEVICE_PATH_PROTOCOL        *FilePathToVerfiy;\r
   \r
   if (FilePath == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -235,6 +242,7 @@ ExecuteSecurityHandlers (
   FileBuffer                  = NULL;\r
   FileSize                    = 0;\r
   HandlerAuthenticationStatus = AuthenticationStatus;\r
+  FilePathToVerfiy            = (EFI_DEVICE_PATH_PROTOCOL *) FilePath;\r
   //\r
   // Run security handler in same order to their registered list\r
   //\r
@@ -244,6 +252,8 @@ ExecuteSecurityHandlers (
       // Try get file buffer when the handler requires image buffer.\r
       //\r
       if (FileBuffer == NULL) {\r
+        Node   = FilePathToVerfiy;\r
+        Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &Node, &Handle);\r
         //\r
         // Try to get image by FALSE boot policy for the exact boot file path.\r
         //\r
@@ -254,11 +264,17 @@ ExecuteSecurityHandlers (
           //\r
           FileBuffer = GetFileBufferByFilePath (TRUE, FilePath, &FileSize, &AuthenticationStatus);\r
         }\r
+        if ((FileBuffer != NULL) && (!EFI_ERROR (Status))) {\r
+          //\r
+          // LoadFile () may cause the device path of the Handle be updated.\r
+          //\r
+          FilePathToVerfiy = AppendDevicePath (DevicePathFromHandle (Handle), Node);\r
+        }\r
       }\r
     }\r
     Status = mSecurityTable[Index].SecurityHandler (\r
                HandlerAuthenticationStatus,\r
-               FilePath,\r
+               FilePathToVerfiy,\r
                FileBuffer,\r
                FileSize\r
                );\r
@@ -270,6 +286,9 @@ ExecuteSecurityHandlers (
   if (FileBuffer != NULL) {\r
     FreePool (FileBuffer);\r
   }\r
+  if (FilePathToVerfiy != FilePath) {\r
+    FreePool (FilePathToVerfiy);\r
+  }\r
 \r
   return Status;\r
 }\r
@@ -283,6 +302,7 @@ ExecuteSecurityHandlers (
 RETURN_STATUS\r
 EFIAPI\r
 ReallocateSecurity2HandlerTable (\r
+  VOID\r
   )\r
 {\r
   //\r