MdeModulePkg/VariableStandaloneMm: Fix TCG MOR secure feature issue

According to TCG's Platform Reset Attack Mitigation spec, the OS should
never create the MOR variable, only read and write it.
But some OSes (Fedora 24 and 25) don't follow the TCG's Platform Reset
Attack Mitigation spec and unintentionally create MOR variable.

The commit fda8f631edbbf3823760542a06f12bd60fd39181 added function
VariableHaveTcgProtocols() to check against Tcg/Tcg2 protocol to infer
whether the MOR variable is created by platform firmware or not. If not,
delete the variable created by OS and lock the variable to avoid OS to
create it.

But in VariableStandaloneMm, VariableHaveTcgProtocols() always returns
FALSE, it causes TCG MOR secure feature does not work in standalone MM
environment.

As Fedora 24 and 25 are EOL today, directly returns TRUE in the function
VariableHaveTcgProtocols() for VariableStandaloneMm, and rename the
function to VariableIsMorVariableLegitimate() to make it more obvious
what the narrow use-case is for which it exists.

Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
This commit is contained in:
Wei6 Xu 2024-08-16 16:33:44 +08:00 committed by mergify[bot]
parent f31aa47dee
commit 5aa6842715
4 changed files with 13 additions and 21 deletions

View File

@ -156,17 +156,13 @@ VariableSmmIsNonPrimaryBufferValid (
);
/**
Whether the TCG or TCG2 protocols are installed in the UEFI protocol database.
This information is used by the MorLock code to infer whether an existing
MOR variable is legitimate or not.
Whether the MOR variable is legitimate or not.
@retval TRUE Either the TCG or TCG2 protocol is installed in the UEFI
protocol database
@retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
protocol database
@retval TRUE MOR Variable is legitimate.
@retval FALSE MOR Variable in not legitimate.
**/
BOOLEAN
VariableHaveTcgProtocols (
VariableIsMorVariableLegitimate (
VOID
);

View File

@ -475,7 +475,7 @@ MorLockInitAtEndOfDxe (
// can be deduced from the absence of the TCG / TCG2 protocols, as edk2's
// MOR implementation depends on (one of) those protocols.
//
if (VariableHaveTcgProtocols ()) {
if (VariableIsMorVariableLegitimate ()) {
//
// The MOR variable originates from the platform firmware; set the MOR
// Control Lock variable to report the locking capability to the OS.

View File

@ -89,19 +89,15 @@ VariableServiceInitialize (
}
/**
Whether the TCG or TCG2 protocols are installed in the UEFI protocol database.
This information is used by the MorLock code to infer whether an existing
MOR variable is legitimate or not.
Whether the MOR variable is legitimate or not.
@retval TRUE Either the TCG or TCG2 protocol is installed in the UEFI
protocol database
@retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
protocol database
@retval TRUE MOR Variable is legitimate.
@retval FALSE MOR Variable in not legitimate.
**/
BOOLEAN
VariableHaveTcgProtocols (
VariableIsMorVariableLegitimate (
VOID
)
{
return FALSE;
return TRUE;
}

View File

@ -118,12 +118,12 @@ VariableServiceInitialize (
MOR variable is legitimate or not.
@retval TRUE Either the TCG or TCG2 protocol is installed in the UEFI
protocol database
protocol database. MOR variable is legitimate.
@retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
protocol database
protocol database. MOR variable is not legitimate.
**/
BOOLEAN
VariableHaveTcgProtocols (
VariableIsMorVariableLegitimate (
VOID
)
{