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
This commit is contained in:
@@ -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
|
||||
//
|
||||
|
@@ -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.
|
||||
|
||||
|
@@ -125,6 +125,7 @@
|
||||
gEfiRuntimeArchProtocolGuid ## CONSUMES
|
||||
gEfiWatchdogTimerArchProtocolGuid ## CONSUMES
|
||||
gEfiSecurityArchProtocolGuid ## CONSUMES
|
||||
gEfiSecurity2ArchProtocolGuid ## CONSUMES
|
||||
gEfiVariableArchProtocolGuid ## CONSUMES
|
||||
gEfiBdsArchProtocolGuid ## CONSUMES
|
||||
gEfiVariableWriteArchProtocolGuid ## CONSUMES
|
||||
|
@@ -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;
|
||||
|
@@ -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 }
|
||||
};
|
||||
|
@@ -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.
|
||||
@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
|
||||
@@ -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;
|
||||
|
||||
//
|
||||
|
@@ -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.
|
||||
|
@@ -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) \
|
||||
|
Reference in New Issue
Block a user