2010-02-24 01:21:16 +01:00
|
|
|
## @file
|
2015-07-01 05:08:29 +02:00
|
|
|
# Provides variable service.
|
2014-08-28 08:34:06 +02:00
|
|
|
#
|
2015-07-01 05:08:29 +02:00
|
|
|
# This module installs variable arch protocol and variable write arch protocol to provide
|
|
|
|
# variable services: SetVariable, GetVariable, GetNextVariableName and QueryVariableInfo.
|
2007-07-19 12:09:07 +02:00
|
|
|
#
|
2014-11-19 02:08:23 +01:00
|
|
|
# Caution: This module requires additional review when modified.
|
|
|
|
# This driver will have external input - variable data.
|
|
|
|
# This external input must be validated carefully to avoid security issues such as
|
|
|
|
# buffer overflow or integer overflow.
|
|
|
|
#
|
2019-01-14 15:27:15 +01:00
|
|
|
# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
|
2020-11-09 07:45:18 +01:00
|
|
|
# Copyright (c) Microsoft Corporation.
|
2019-04-04 01:05:13 +02:00
|
|
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
2007-07-19 12:09:07 +02:00
|
|
|
#
|
2010-02-24 01:21:16 +01:00
|
|
|
##
|
2007-07-19 12:09:07 +02:00
|
|
|
|
|
|
|
[Defines]
|
|
|
|
INF_VERSION = 0x00010005
|
|
|
|
BASE_NAME = VariableRuntimeDxe
|
2014-08-28 08:34:06 +02:00
|
|
|
MODULE_UNI_FILE = VariableRuntimeDxe.uni
|
2007-07-19 12:09:07 +02:00
|
|
|
FILE_GUID = CBD2E4D5-7068-4FF5-B462-9822B4AD8D60
|
|
|
|
MODULE_TYPE = DXE_RUNTIME_DRIVER
|
|
|
|
VERSION_STRING = 1.0
|
|
|
|
ENTRY_POINT = VariableServiceInitialize
|
|
|
|
|
|
|
|
#
|
|
|
|
# The following information is for reference only and not required by the build tools.
|
|
|
|
#
|
2008-10-28 08:17:17 +01:00
|
|
|
# VALID_ARCHITECTURES = IA32 X64 EBC
|
2007-07-19 12:09:07 +02:00
|
|
|
#
|
|
|
|
# VIRTUAL_ADDRESS_MAP_CALLBACK = VariableClassAddressChangeEvent
|
|
|
|
#
|
|
|
|
|
2010-02-24 01:21:16 +01:00
|
|
|
[Sources]
|
2008-12-14 06:40:01 +01:00
|
|
|
Reclaim.c
|
2007-07-19 12:09:07 +02:00
|
|
|
Variable.c
|
2010-12-10 10:27:54 +01:00
|
|
|
VariableDxe.c
|
2007-07-19 12:09:07 +02:00
|
|
|
Variable.h
|
2019-09-28 00:34:14 +02:00
|
|
|
VariableNonVolatile.c
|
|
|
|
VariableNonVolatile.h
|
2019-09-24 02:32:07 +02:00
|
|
|
VariableParsing.c
|
|
|
|
VariableParsing.h
|
2019-09-24 01:48:09 +02:00
|
|
|
VariableRuntimeCache.c
|
|
|
|
VariableRuntimeCache.h
|
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>
2017-09-30 13:40:32 +02:00
|
|
|
PrivilegePolymorphic.h
|
2015-07-01 05:08:29 +02:00
|
|
|
Measurement.c
|
2016-01-19 14:22:05 +01:00
|
|
|
TcgMorLockDxe.c
|
2015-01-05 04:38:36 +01:00
|
|
|
VarCheck.c
|
2015-07-01 05:08:29 +02:00
|
|
|
VariableExLib.c
|
2018-12-21 03:30:22 +01:00
|
|
|
SpeculationBarrierDxe.c
|
2020-11-09 07:45:22 +01:00
|
|
|
VariableLockRequestToLock.c
|
2007-07-19 12:09:07 +02:00
|
|
|
|
|
|
|
[Packages]
|
|
|
|
MdePkg/MdePkg.dec
|
2007-08-29 10:52:49 +02:00
|
|
|
MdeModulePkg/MdeModulePkg.dec
|
2007-07-19 12:09:07 +02:00
|
|
|
|
|
|
|
[LibraryClasses]
|
|
|
|
MemoryAllocationLib
|
|
|
|
BaseLib
|
2009-01-30 01:33:39 +01:00
|
|
|
SynchronizationLib
|
2007-07-19 12:09:07 +02:00
|
|
|
UefiLib
|
|
|
|
UefiBootServicesTableLib
|
|
|
|
BaseMemoryLib
|
|
|
|
DebugLib
|
|
|
|
UefiRuntimeLib
|
|
|
|
DxeServicesTableLib
|
|
|
|
UefiDriverEntryPoint
|
|
|
|
PcdLib
|
2011-10-14 07:19:39 +02:00
|
|
|
HobLib
|
2015-07-01 05:08:29 +02:00
|
|
|
TpmMeasurementLib
|
|
|
|
AuthVariableLib
|
2015-08-25 05:01:56 +02:00
|
|
|
VarCheckLib
|
2020-11-09 07:45:18 +01:00
|
|
|
VariablePolicyLib
|
2020-11-09 07:45:21 +01:00
|
|
|
VariablePolicyHelperLib
|
2007-07-19 12:09:07 +02:00
|
|
|
|
|
|
|
[Protocols]
|
2014-08-28 08:34:06 +02:00
|
|
|
gEfiFirmwareVolumeBlockProtocolGuid ## CONSUMES
|
|
|
|
## CONSUMES
|
|
|
|
## NOTIFY
|
|
|
|
gEfiFaultTolerantWriteProtocolGuid
|
|
|
|
gEfiVariableWriteArchProtocolGuid ## PRODUCES
|
|
|
|
gEfiVariableArchProtocolGuid ## PRODUCES
|
|
|
|
gEdkiiVariableLockProtocolGuid ## PRODUCES
|
2020-11-09 07:45:21 +01:00
|
|
|
gEdkiiVariablePolicyProtocolGuid ## CONSUMES
|
2015-01-05 04:38:36 +01:00
|
|
|
gEdkiiVarCheckProtocolGuid ## PRODUCES
|
2007-07-19 12:09:07 +02:00
|
|
|
|
2007-10-04 23:01:21 +02:00
|
|
|
[Guids]
|
2016-03-25 10:24:37 +01:00
|
|
|
## SOMETIMES_CONSUMES ## GUID # Signature of Variable store header
|
|
|
|
## SOMETIMES_PRODUCES ## GUID # Signature of Variable store header
|
2015-07-01 05:08:29 +02:00
|
|
|
## SOMETIMES_CONSUMES ## HOB
|
|
|
|
## SOMETIMES_PRODUCES ## SystemTable
|
|
|
|
gEfiAuthenticatedVariableGuid
|
|
|
|
|
2016-03-25 10:24:37 +01:00
|
|
|
## SOMETIMES_CONSUMES ## GUID # Signature of Variable store header
|
|
|
|
## SOMETIMES_PRODUCES ## GUID # Signature of Variable store header
|
2014-08-28 08:34:06 +02:00
|
|
|
## SOMETIMES_CONSUMES ## HOB
|
|
|
|
## SOMETIMES_PRODUCES ## SystemTable
|
|
|
|
gEfiVariableGuid
|
2015-07-01 05:08:29 +02:00
|
|
|
|
2014-08-28 08:34:06 +02:00
|
|
|
## SOMETIMES_CONSUMES ## Variable:L"PlatformLang"
|
|
|
|
## SOMETIMES_PRODUCES ## Variable:L"PlatformLang"
|
|
|
|
## SOMETIMES_CONSUMES ## Variable:L"Lang"
|
|
|
|
## SOMETIMES_PRODUCES ## Variable:L"Lang"
|
2017-01-18 04:32:47 +01:00
|
|
|
## SOMETIMES_CONSUMES ## Variable:L"PK"
|
|
|
|
## SOMETIMES_CONSUMES ## Variable:L"KEK"
|
|
|
|
## SOMETIMES_CONSUMES ## Variable:L"SecureBoot"
|
2014-08-28 08:34:06 +02:00
|
|
|
gEfiGlobalVariableGuid
|
2015-07-01 05:08:29 +02:00
|
|
|
|
2016-03-25 10:24:37 +01:00
|
|
|
gEfiMemoryOverwriteControlDataGuid ## SOMETIMES_CONSUMES ## Variable:L"MemoryOverwriteRequestControl"
|
|
|
|
gEfiMemoryOverwriteRequestControlLockGuid ## SOMETIMES_PRODUCES ## Variable:L"MemoryOverwriteRequestControlLock"
|
2016-01-19 14:22:05 +01:00
|
|
|
|
2014-08-28 08:34:06 +02:00
|
|
|
gEfiEventVirtualAddressChangeGuid ## CONSUMES ## Event
|
|
|
|
gEfiSystemNvDataFvGuid ## CONSUMES ## GUID
|
|
|
|
gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event
|
2015-07-01 05:08:29 +02:00
|
|
|
gEdkiiFaultTolerantWriteGuid ## SOMETIMES_CONSUMES ## HOB
|
2016-03-25 10:24:37 +01:00
|
|
|
|
|
|
|
## SOMETIMES_CONSUMES ## Variable:L"VarErrorFlag"
|
|
|
|
## SOMETIMES_PRODUCES ## Variable:L"VarErrorFlag"
|
|
|
|
gEdkiiVarErrorFlagGuid
|
2007-10-04 23:01:21 +02:00
|
|
|
|
2017-01-18 04:32:47 +01:00
|
|
|
## SOMETIMES_CONSUMES ## Variable:L"db"
|
|
|
|
## SOMETIMES_CONSUMES ## Variable:L"dbx"
|
|
|
|
## SOMETIMES_CONSUMES ## Variable:L"dbt"
|
2015-10-16 03:32:22 +02:00
|
|
|
gEfiImageSecurityDatabaseGuid
|
|
|
|
|
2010-02-24 01:21:16 +01:00
|
|
|
[Pcd]
|
2014-08-28 08:34:06 +02:00
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## CONSUMES
|
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## SOMETIMES_CONSUMES
|
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 ## CONSUMES
|
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize ## CONSUMES
|
2015-07-01 05:08:29 +02:00
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize ## CONSUMES
|
MdeModulePkg/Variable/RuntimeDxe: introduce PcdMaxVolatileVariableSize
The variable driver doesn't distinguish "non-volatile non-authenticated"
variables from "volatile non-authenticated" variables, when checking
individual variable sizes against the permitted maximum.
PcdMaxVariableSize covers both kinds.
This prevents volatile non-authenticated variables from carrying large
data between UEFI drivers, despite having no flash impact. One example is
EFI_TLS_CA_CERTIFICATE_VARIABLE, which platforms might want to create as
volatile on every boot: the certificate list can be several hundred KB in
size.
Introduce PcdMaxVolatileVariableSize to represent the limit on individual
volatile non-authenticated variables. The default value is zero, which
makes Variable/RuntimeDxe fall back to PcdMaxVariableSize (i.e. the
current behavior). This is similar to the PcdMaxAuthVariableSize fallback.
Whenever the size limit is enforced, consult MaxVolatileVariableSize as
the last option, after checking
- MaxAuthVariableSize for VARIABLE_ATTRIBUTE_AT_AW,
- and MaxVariableSize for EFI_VARIABLE_NON_VOLATILE.
EFI_VARIABLE_HARDWARE_ERROR_RECORD is always handled separately; it always
takes priority over the three cases listed above.
Introduce the GetMaxVariableSize() helper to consider
PcdMaxVolatileVariableSize, in addition to
GetNonVolatileMaxVariableSize(). GetNonVolatileMaxVariableSize() is
currently called at three sites, and two of those need to start using
GetMaxVariableSize() instead:
- VariableServiceInitialize() [VariableSmm.c]: the SMM comms buffer must
accommodate all kinds of variables,
- VariableCommonInitialize() [Variable.c]: the preallocated scratch space
must also accommodate all kinds of variables,
- InitNonVolatileVariableStore() [Variable.c] can continue using
GetNonVolatileMaxVariableSize().
Don't modify the ReclaimForOS() function as it is specific to non-volatile
variables and should ignore PcdMaxVolatileVariableSize.
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.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: Gary Lin <glin@suse.com>
Tested-by: Gary Lin <glin@suse.com>
[lersek@redhat.com: set MaxVolatileVariableSize where Star suggested]
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-28 15:55:42 +02:00
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVolatileVariableSize ## CONSUMES
|
2014-08-28 08:34:06 +02:00
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize ## CONSUMES
|
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize ## CONSUMES
|
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdHwErrStorageSize ## CONSUMES
|
2015-01-27 09:42:47 +01:00
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxUserNvVariableSpaceSize ## CONSUMES
|
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdBoottimeReservedNvVariableSpaceSize ## CONSUMES
|
2015-02-02 10:30:34 +01:00
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdReclaimVariableSpaceAtEndOfDxe ## CONSUMES
|
2019-01-14 15:27:15 +01:00
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable ## SOMETIMES_CONSUMES
|
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved ## SOMETIMES_CONSUMES
|
2015-02-02 10:30:34 +01:00
|
|
|
|
2010-02-24 01:21:16 +01:00
|
|
|
[FeaturePcd]
|
2014-03-25 07:56:55 +01:00
|
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics ## CONSUMES # statistic the information of variable.
|
2015-07-01 05:08:29 +02:00
|
|
|
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate ## CONSUMES # Auto update PlatformLang/Lang
|
2007-07-19 12:09:07 +02:00
|
|
|
|
|
|
|
[Depex]
|
2010-12-10 10:27:54 +01:00
|
|
|
TRUE
|
2007-07-19 12:09:07 +02:00
|
|
|
|
2014-08-28 08:34:06 +02:00
|
|
|
[UserExtensions.TianoCore."ExtraFiles"]
|
|
|
|
VariableRuntimeDxeExtra.uni
|