summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core/Dxe
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-22 02:32:12 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-22 02:32:12 +0000
commitbc2dfdbcfc11dc785f0cc0ad2f519a63b98f88bc (patch)
treea845bde22c55b227897be7e7b2a21059f12c967e /MdeModulePkg/Core/Dxe
parent53cdd43979f70b01a4ba341b54a4aef595420dbf (diff)
downloadedk2-bc2dfdbcfc11dc785f0cc0ad2f519a63b98f88bc.zip
edk2-bc2dfdbcfc11dc785f0cc0ad2f519a63b98f88bc.tar.gz
edk2-bc2dfdbcfc11dc785f0cc0ad2f519a63b98f88bc.tar.bz2
Add PI1.2.1 SAP2 support and UEFI231B mantis 896
1. Update SecurityManagementLib to support SAP2 and SAP services. 2. Update SecurityStub driver to produce SAP2 and SAP protocol both. 3. Update DxeCore and SmmCore to use SAP2 and SAP service to verify Image. 4. Update DxeCore ConnectController() to use SAP2 service to check user permission. Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Guo Dong <dong.guo@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13660 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Core/Dxe')
-rw-r--r--MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c15
-rw-r--r--MdeModulePkg/Core/Dxe/DxeMain.h35
-rw-r--r--MdeModulePkg/Core/Dxe/DxeMain.inf1
-rw-r--r--MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c1
-rw-r--r--MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c1
-rw-r--r--MdeModulePkg/Core/Dxe/Hand/DriverSupport.c74
-rw-r--r--MdeModulePkg/Core/Dxe/Image/Image.c81
-rw-r--r--MdeModulePkg/Core/Dxe/Image/Image.h3
8 files changed, 164 insertions, 47 deletions
diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
index 3a7e0db..848eb4b 100644
--- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
@@ -89,9 +89,18 @@ typedef struct {
EFI_DEVICE_PATH_PROTOCOL End;
} FV_FILEPATH_DEVICE_PATH;
-FV_FILEPATH_DEVICE_PATH mFvDevicePath;
-
-
+FV_FILEPATH_DEVICE_PATH mFvDevicePath = {
+ {
+ 0
+ },
+ {
+ END_DEVICE_PATH_TYPE,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ {
+ END_DEVICE_PATH_LENGTH
+ }
+ }
+};
//
// Function Prototypes
//
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h
index 53b5f59..79e6517 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.h
+++ b/MdeModulePkg/Core/Dxe/DxeMain.h
@@ -41,6 +41,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/Decompress.h>
#include <Protocol/LoadPe32Image.h>
#include <Protocol/Security.h>
+#include <Protocol/Security2.h>
#include <Protocol/Ebc.h>
#include <Protocol/Reset.h>
#include <Protocol/Cpu.h>
@@ -204,6 +205,7 @@ extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer;
extern EFI_METRONOME_ARCH_PROTOCOL *gMetronome;
extern EFI_TIMER_ARCH_PROTOCOL *gTimer;
extern EFI_SECURITY_ARCH_PROTOCOL *gSecurity;
+extern EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2;
extern EFI_BDS_ARCH_PROTOCOL *gBds;
extern EFI_SMM_BASE2_PROTOCOL *gSmmBase2;
@@ -1081,19 +1083,27 @@ CoreConnectHandlesByKey (
/**
Connects one or more drivers to a controller.
- @param ControllerHandle Handle of the controller to be
- connected.
- @param DriverImageHandle DriverImageHandle A pointer to an
- ordered list of driver image
- handles.
- @param RemainingDevicePath RemainingDevicePath A pointer to
- the device path that specifies a
- child of the controller specified
- by ControllerHandle.
- @param Recursive Whether the function would be
- called recursively or not.
+ @param ControllerHandle The handle of the controller to which driver(s) are to be connected.
+ @param DriverImageHandle A pointer to an ordered list handles that support the
+ EFI_DRIVER_BINDING_PROTOCOL.
+ @param RemainingDevicePath A pointer to the device path that specifies a child of the
+ controller specified by ControllerHandle.
+ @param Recursive If TRUE, then ConnectController() is called recursively
+ until the entire tree of controllers below the controller specified
+ by ControllerHandle have been created. If FALSE, then
+ the tree of controllers is only expanded one level.
- @return Status code.
+ @retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle.
+ 2) No drivers were connected to ControllerHandle, but
+ RemainingDevicePath is not NULL, and it is an End Device
+ Path Node.
+ @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
+ @retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances
+ present in the system.
+ 2) No drivers were connected to ControllerHandle.
+ @retval EFI_SECURITY_VIOLATION
+ The user has no permission to start UEFI device drivers on the device path
+ associated with the ControllerHandle or specified by the RemainingDevicePath.
**/
EFI_STATUS
@@ -1361,6 +1371,7 @@ CoreUnloadImage (
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
+ @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.
@retval EFI_SUCCESS Successfully transfer control to the image's
entry point.
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf
index 0fe0259..6be08fe 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.inf
+++ b/MdeModulePkg/Core/Dxe/DxeMain.inf
@@ -125,6 +125,7 @@
gEfiRuntimeArchProtocolGuid ## CONSUMES
gEfiWatchdogTimerArchProtocolGuid ## CONSUMES
gEfiSecurityArchProtocolGuid ## CONSUMES
+ gEfiSecurity2ArchProtocolGuid ## CONSUMES
gEfiVariableArchProtocolGuid ## CONSUMES
gEfiBdsArchProtocolGuid ## CONSUMES
gEfiVariableWriteArchProtocolGuid ## CONSUMES
diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
index a6d10e6..e1ba34a 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
+++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
@@ -23,6 +23,7 @@ EFI_HANDLE mDecompressHandle = NULL;
// DXE Core globals for Architecture Protocols
//
EFI_SECURITY_ARCH_PROTOCOL *gSecurity = NULL;
+EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2 = NULL;
EFI_CPU_ARCH_PROTOCOL *gCpu = NULL;
EFI_METRONOME_ARCH_PROTOCOL *gMetronome = NULL;
EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL;
diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c
index de129c2..e5405b3 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c
+++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c
@@ -45,6 +45,7 @@ EFI_CORE_PROTOCOL_NOTIFY_ENTRY mArchProtocols[] = {
// Optional protocols that the DXE Core will use if they are present
//
EFI_CORE_PROTOCOL_NOTIFY_ENTRY mOptionalProtocols[] = {
+ { &gEfiSecurity2ArchProtocolGuid, (VOID **)&gSecurity2, NULL, NULL, FALSE },
{ &gEfiSmmBase2ProtocolGuid, (VOID **)&gSmmBase2, NULL, NULL, FALSE },
{ NULL, (VOID **)NULL, NULL, NULL, FALSE }
};
diff --git a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c
index d705899..ded6356 100644
--- a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c
+++ b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c
@@ -1,7 +1,7 @@
/** @file
Support functions to connect/disconnect UEFI Driver model Protocol
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, 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
@@ -22,19 +22,27 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/**
Connects one or more drivers to a controller.
- @param ControllerHandle Handle of the controller to be
- connected.
- @param DriverImageHandle DriverImageHandle A pointer to an
- ordered list of driver image
- handles.
- @param RemainingDevicePath RemainingDevicePath A pointer to
- the device path that specifies a
- child of the controller specified
- by ControllerHandle.
- @param Recursive Whether the function would be
- called recursively or not.
-
- @return Status code.
+ @param ControllerHandle The handle of the controller to which driver(s) are to be connected.
+ @param DriverImageHandle A pointer to an ordered list handles that support the
+ EFI_DRIVER_BINDING_PROTOCOL.
+ @param RemainingDevicePath A pointer to the device path that specifies a child of the
+ controller specified by ControllerHandle.
+ @param Recursive If TRUE, then ConnectController() is called recursively
+ until the entire tree of controllers below the controller specified
+ by ControllerHandle have been created. If FALSE, then
+ the tree of controllers is only expanded one level.
+
+ @retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle.
+ 2) No drivers were connected to ControllerHandle, but
+ RemainingDevicePath is not NULL, and it is an End Device
+ Path Node.
+ @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
+ @retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances
+ present in the system.
+ 2) No drivers were connected to ControllerHandle.
+ @retval EFI_SECURITY_VIOLATION
+ The user has no permission to start UEFI device drivers on the device path
+ associated with the ControllerHandle or specified by the RemainingDevicePath.
**/
EFI_STATUS
@@ -57,6 +65,11 @@ CoreConnectController (
EFI_HANDLE *ChildHandleBuffer;
UINTN ChildHandleCount;
UINTN Index;
+ UINTN HandleFilePathSize;
+ UINTN RemainingDevicePathSize;
+ EFI_DEVICE_PATH_PROTOCOL *HandleFilePath;
+ EFI_DEVICE_PATH_PROTOCOL *FilePath;
+ EFI_DEVICE_PATH_PROTOCOL *TempFilePath;
//
// Make sure ControllerHandle is valid
@@ -66,6 +79,39 @@ CoreConnectController (
return Status;
}
+ if (gSecurity2 != NULL) {
+ //
+ // Check whether the user has permission to start UEFI device drivers.
+ //
+ Status = CoreHandleProtocol (ControllerHandle, &gEfiDevicePathProtocolGuid, (VOID **)&HandleFilePath);
+ if (!EFI_ERROR (Status)) {
+ FilePath = HandleFilePath;
+ TempFilePath = NULL;
+ if (RemainingDevicePath != NULL && !Recursive) {
+ HandleFilePathSize = GetDevicePathSize (HandleFilePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL);
+ RemainingDevicePathSize = GetDevicePathSize (RemainingDevicePath);
+ TempFilePath = AllocateZeroPool (HandleFilePathSize + RemainingDevicePathSize);
+ ASSERT (TempFilePath != NULL);
+ CopyMem (TempFilePath, HandleFilePath, HandleFilePathSize);
+ CopyMem ((UINT8 *) TempFilePath + HandleFilePathSize, RemainingDevicePath, RemainingDevicePathSize);
+ FilePath = TempFilePath;
+ }
+ Status = gSecurity2->FileAuthentication (
+ gSecurity2,
+ FilePath,
+ NULL,
+ 0,
+ FALSE
+ );
+ if (TempFilePath != NULL) {
+ FreePool (TempFilePath);
+ }
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+ }
+
Handle = ControllerHandle;
//
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c
index 32f3898..a3cffce 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.c
+++ b/MdeModulePkg/Core/Dxe/Image/Image.c
@@ -1044,6 +1044,7 @@ CoreLoadImageCommon (
EFI_DEVICE_PATH_PROTOCOL *OriginalFilePath;
EFI_DEVICE_PATH_PROTOCOL *HandleFilePath;
UINTN FilePathSize;
+ BOOLEAN ImageIsFromFv;
SecurityStatus = EFI_SUCCESS;
@@ -1070,6 +1071,8 @@ CoreLoadImageCommon (
DeviceHandle = NULL;
Status = EFI_SUCCESS;
AuthenticationStatus = 0;
+ ImageIsFromFv = FALSE;
+
//
// If the caller passed a copy of the file, then just use it
//
@@ -1103,7 +1106,9 @@ CoreLoadImageCommon (
//
FHand.FreeBuffer = TRUE;
Status = CoreLocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &HandleFilePath, &DeviceHandle);
- if (EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status)) {
+ ImageIsFromFv = TRUE;
+ } else {
HandleFilePath = FilePath;
Status = CoreLocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &HandleFilePath, &DeviceHandle);
if (EFI_ERROR (Status)) {
@@ -1127,29 +1132,59 @@ CoreLoadImageCommon (
return Status;
}
- //
- // Verify the Authentication Status through the Security Architectural Protocol
- //
- if ((gSecurity != NULL) && (OriginalFilePath != NULL)) {
+ if (gSecurity2 != NULL) {
+ //
+ // Verify File Authentication through the Security2 Architectural Protocol
+ //
+ SecurityStatus = gSecurity2->FileAuthentication (
+ gSecurity2,
+ OriginalFilePath,
+ FHand.Source,
+ FHand.SourceSize,
+ BootPolicy
+ );
+ if (!EFI_ERROR (SecurityStatus) && ImageIsFromFv) {
+ //
+ // When Security2 is installed, Security Architectural Protocol must be published.
+ //
+ ASSERT (gSecurity != NULL);
+
+ //
+ // Verify the Authentication Status through the Security Architectural Protocol
+ // Only on images that have been read using Firmware Volume protocol.
+ //
+ SecurityStatus = gSecurity->FileAuthenticationState (
+ gSecurity,
+ AuthenticationStatus,
+ OriginalFilePath
+ );
+ }
+ } else if ((gSecurity != NULL) && (OriginalFilePath != NULL)) {
+ //
+ // Verify the Authentication Status through the Security Architectural Protocol
+ //
SecurityStatus = gSecurity->FileAuthenticationState (
gSecurity,
AuthenticationStatus,
OriginalFilePath
);
- if (EFI_ERROR (SecurityStatus) && SecurityStatus != EFI_SECURITY_VIOLATION) {
- if (SecurityStatus == EFI_ACCESS_DENIED) {
- //
- // Image was not loaded because the platform policy prohibits the image from being loaded.
- // It's the only place we could meet EFI_ACCESS_DENIED.
- //
- *ImageHandle = NULL;
- }
- Status = SecurityStatus;
- Image = NULL;
- goto Done;
- }
}
+ //
+ // Check Security Status.
+ //
+ if (EFI_ERROR (SecurityStatus) && SecurityStatus != EFI_SECURITY_VIOLATION) {
+ if (SecurityStatus == EFI_ACCESS_DENIED) {
+ //
+ // Image was not loaded because the platform policy prohibits the image from being loaded.
+ // It's the only place we could meet EFI_ACCESS_DENIED.
+ //
+ *ImageHandle = NULL;
+ }
+ Status = SecurityStatus;
+ Image = NULL;
+ goto Done;
+ }
//
// Allocate a new image structure
@@ -1295,11 +1330,19 @@ Done:
if (EFI_ERROR (Status)) {
if (Image != NULL) {
CoreUnloadAndCloseImage (Image, (BOOLEAN)(DstBuffer == 0));
+ Image = NULL;
}
} else if (EFI_ERROR (SecurityStatus)) {
Status = SecurityStatus;
}
+ //
+ // Track the return status from LoadImage.
+ //
+ if (Image != NULL) {
+ Image->LoadImageStatus = Status;
+ }
+
return Status;
}
@@ -1492,6 +1535,7 @@ CoreLoadImageEx (
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
+ @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.
@retval EFI_SUCCESS Successfully transfer control to the image's
entry point.
@@ -1519,6 +1563,9 @@ CoreStartImage (
if (Image == NULL || Image->Started) {
return EFI_INVALID_PARAMETER;
}
+ if (EFI_ERROR (Image->LoadImageStatus)) {
+ return Image->LoadImageStatus;
+ }
//
// The image to be started must have the machine type supported by DxeCore.
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.h b/MdeModulePkg/Core/Dxe/Image/Image.h
index 2d4c288..e9240c0 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.h
+++ b/MdeModulePkg/Core/Dxe/Image/Image.h
@@ -58,7 +58,8 @@ typedef struct {
EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
/// PeCoffLoader ImageContext
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
-
+ /// Status returned by LoadImage() service.
+ EFI_STATUS LoadImageStatus;
} LOADED_IMAGE_PRIVATE_DATA;
#define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \