mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
MdeModulePkg/Variable/RuntimeDxe: move SecureBootHook() decl to new header
If the platform supports SMM, a gRT->SetVariable() call at boot time results in the following call tree to SecureBootHook(): RuntimeServiceSetVariable() [VariableSmmRuntimeDxe.c, unprivileged] SmmVariableHandler() [VariableSmm.c, PRIVILEGED] VariableServiceSetVariable() [Variable.c, PRIVILEGED] SecureBootHook() [VariableSmm.c, PRIVILEGED] // // do nothing // SecureBootHook() [Measurement.c, unprivileged] // // measure variable if it // is related to SB policy // And if the platform does not support SMM: VariableServiceSetVariable() [Variable.c, unprivileged] SecureBootHook() [Measurement.c, unprivileged] // // measure variable if it // is related to SB policy // In other words, the measurement always happens outside of SMM. Because there are two implementations of the SecureBootHook() API, one that is called from SMM and does nothing, and another that is called outside of SMM and measures variables, the function declaration should be in a header file. This way the compiler can enforce that the function declaration and all function definitions match. "Variable.h" is used for "including common header files, defining internal structures and functions used by Variable modules". Technically, we could declare SecureBootHook() in "Variable.h". However, "Measurement.c" and "VariableSmmRuntimeDxe.c" themselves do not include "Variable.h", and that is likely intentional -- "Variable.h" exposes so much of the privileged variable implementation that it is likely excluded from these C source files on purpose. Therefore introduce a new header file called "PrivilegePolymorphic.h". "Variable.h" includes this header (so that all C source files that have been allowed to see the variable internals learn about the new SecureBootHook() declaration immediately). In "Measurement.c" and "VariableSmmRuntimeDxe.c", include *only* the new header. This change cleans up commit fa0737a839d0 ("MdeModulePkg Variable: Merge from Auth Variable driver in SecurityPkg", 2015-07-01). Cc: Eric Dong <eric.dong@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Ladi Prosek <lprosek@redhat.com> Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Tested-by: Ladi Prosek <lprosek@redhat.com>
This commit is contained in:
parent
35ac962b54
commit
00663d047f
@ -24,6 +24,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/TpmMeasurementLib.h>
|
||||
|
||||
#include "PrivilegePolymorphic.h"
|
||||
|
||||
typedef struct {
|
||||
CHAR16 *VariableName;
|
||||
EFI_GUID *VendorGuid;
|
||||
|
@ -0,0 +1,38 @@
|
||||
/** @file
|
||||
Polymorphic functions that are called from both the privileged driver (i.e.,
|
||||
the DXE_SMM variable module) and the non-privileged drivers (i.e., one or
|
||||
both of the DXE_RUNTIME variable modules).
|
||||
|
||||
Each of these functions has two implementations, appropriate for privileged
|
||||
vs. non-privileged driver code.
|
||||
|
||||
Copyright (c) 2017, Red Hat, Inc.<BR>
|
||||
Copyright (c) 2010 - 2017, 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
**/
|
||||
#ifndef _PRIVILEGE_POLYMORPHIC_H_
|
||||
#define _PRIVILEGE_POLYMORPHIC_H_
|
||||
|
||||
#include <Uefi/UefiBaseType.h>
|
||||
|
||||
/**
|
||||
SecureBoot Hook for auth variable update.
|
||||
|
||||
@param[in] VariableName Name of Variable to be found.
|
||||
@param[in] VendorGuid Variable vendor GUID.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
SecureBootHook (
|
||||
IN CHAR16 *VariableName,
|
||||
IN EFI_GUID *VendorGuid
|
||||
);
|
||||
|
||||
#endif
|
@ -97,20 +97,6 @@ AUTH_VAR_LIB_CONTEXT_IN mAuthContextIn = {
|
||||
|
||||
AUTH_VAR_LIB_CONTEXT_OUT mAuthContextOut;
|
||||
|
||||
/**
|
||||
|
||||
SecureBoot Hook for auth variable update.
|
||||
|
||||
@param[in] VariableName Name of Variable to be found.
|
||||
@param[in] VendorGuid Variable vendor GUID.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
SecureBootHook (
|
||||
IN CHAR16 *VariableName,
|
||||
IN EFI_GUID *VendorGuid
|
||||
);
|
||||
|
||||
/**
|
||||
Initialization for MOR Lock Control.
|
||||
|
||||
|
@ -44,6 +44,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#include <Guid/FaultTolerantWrite.h>
|
||||
#include <Guid/VarErrorFlag.h>
|
||||
|
||||
#include "PrivilegePolymorphic.h"
|
||||
|
||||
#define EFI_VARIABLE_ATTRIBUTES_MASK (EFI_VARIABLE_NON_VOLATILE | \
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | \
|
||||
EFI_VARIABLE_RUNTIME_ACCESS | \
|
||||
|
@ -41,6 +41,7 @@
|
||||
Variable.c
|
||||
VariableDxe.c
|
||||
Variable.h
|
||||
PrivilegePolymorphic.h
|
||||
Measurement.c
|
||||
TcgMorLockDxe.c
|
||||
VarCheck.c
|
||||
|
@ -51,6 +51,7 @@
|
||||
VariableSmm.c
|
||||
VarCheck.c
|
||||
Variable.h
|
||||
PrivilegePolymorphic.h
|
||||
VariableExLib.c
|
||||
TcgMorLockSmm.c
|
||||
|
||||
|
@ -44,6 +44,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#include <Guid/EventGroup.h>
|
||||
#include <Guid/SmmVariableCommon.h>
|
||||
|
||||
#include "PrivilegePolymorphic.h"
|
||||
|
||||
EFI_HANDLE mHandle = NULL;
|
||||
EFI_SMM_VARIABLE_PROTOCOL *mSmmVariable = NULL;
|
||||
EFI_EVENT mVirtualAddressChangeEvent = NULL;
|
||||
@ -56,20 +58,6 @@ EFI_LOCK mVariableServicesLock;
|
||||
EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock;
|
||||
EDKII_VAR_CHECK_PROTOCOL mVarCheck;
|
||||
|
||||
/**
|
||||
SecureBoot Hook for SetVariable.
|
||||
|
||||
@param[in] VariableName Name of Variable to be found.
|
||||
@param[in] VendorGuid Variable vendor GUID.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
SecureBootHook (
|
||||
IN CHAR16 *VariableName,
|
||||
IN EFI_GUID *VendorGuid
|
||||
);
|
||||
|
||||
/**
|
||||
Some Secure Boot Policy Variable may update following other variable changes(SecureBoot follows PK change, etc).
|
||||
Record their initial State when variable write service is ready.
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
[Sources]
|
||||
VariableSmmRuntimeDxe.c
|
||||
PrivilegePolymorphic.h
|
||||
Measurement.c
|
||||
|
||||
[Packages]
|
||||
|
Loading…
x
Reference in New Issue
Block a user