MdeModulePkg/Variable/RuntimeDxe: Do not clobber Attributes on error

FindVariableInSmm() copied Attributes from the SMM response back to the
caller even when GetVariable returned an error (e.g. EFI_NOT_FOUND). In
the EFI_NOT_FOUND case, the returned Attributes value is 0, which
overwrote the caller-provided Attributes.

This differs from the native VariableServiceGetVariable() path, which
only updates Attributes on EFI_SUCCESS or EFI_BUFFER_TOO_SMALL. In the
SMM path, clobbering Attributes on error can cause subsequent SetVariable
calls to use incorrect attributes (e.g. losing TIME_BASED_AUTH), which
breaks UEFI-SCT authenticated variable tests when using the SMM gateway
backend.

Only copy Attributes back to the caller on EFI_SUCCESS or
EFI_BUFFER_TOO_SMALL, preserving the caller-provided value on errors.

Signed-off-by: Gianluca Andreotti <gianluca.andreotti@arm.com>
This commit is contained in:
Gianluca Andreotti 2026-01-13 14:03:46 +00:00 committed by Gianluca Andreotti
parent ffaaf0f14c
commit ec3cc61a8b

View file

@ -13,6 +13,7 @@
InitCommunicateBuffer() is really function to check the variable data size.
Copyright (c) 2026, ARM Ltd. All rights reserved.<BR>
Copyright (c) 2010 - 2024, Intel Corporation. All rights reserved.<BR>
Copyright (c) Microsoft Corporation.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@ -760,10 +761,10 @@ FindVariableInSmm (
// Only update DataSize when needed
//
*DataSize = SmmVariableHeader->DataSize;
}
if (Attributes != NULL) {
*Attributes = SmmVariableHeader->Attributes;
if (Attributes != NULL) {
*Attributes = SmmVariableHeader->Attributes;
}
}
if (EFI_ERROR (Status)) {