summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorSunny Wang <Sunny.Wang@arm.com>2022-01-12 05:37:20 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-01-21 02:13:31 +0000
commit21320ef66989f8af5a9e9b57df73d20a70bea85f (patch)
tree15d8f6e157580ffd9aada777ee4ff3ef06693c24 /MdeModulePkg
parent7709988dd8f9a69eea456869f468120f1f0fc7cb (diff)
downloadedk2-21320ef66989f8af5a9e9b57df73d20a70bea85f.tar.gz
edk2-21320ef66989f8af5a9e9b57df73d20a70bea85f.tar.bz2
edk2-21320ef66989f8af5a9e9b57df73d20a70bea85f.zip
MdeModulePkg/Variable: Make only EFI_VARIABLE_NON_VOLATILE invalid
Only EFI_VARIABLE_NON_VOLATILE attribute is an invalid combination of attribute bits, so update the variable driver to return EFI_INVALID_PARAMETER so that we can prevent the invalid variable being created. This change also fixes the SCT failure below: - RT.QueryVariableInfo - With being an invalid combination -- FAILURE For details, please check the threads below: - https://edk2.groups.io/g/devel/topic/86486174 - https://edk2.groups.io/g/devel/message/82466 Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Cc: G Edhaya Chandran <edhaya.chandran@arm.com> Cc: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@arm.com> Signed-off-by: Sunny Wang <sunny.wang@arm.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 9722a94420..6c1a3440ac 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -19,6 +19,7 @@
Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) Microsoft Corporation.<BR>
+Copyright (c) 2022, ARM Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -2660,14 +2661,22 @@ VariableServiceSetVariable (
}
//
- // Make sure if runtime bit is set, boot service bit is set also.
+ // Check if the combination of attribute bits is valid.
//
if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {
+ //
+ // Make sure if runtime bit is set, boot service bit is set also.
+ //
if ((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {
return EFI_UNSUPPORTED;
} else {
return EFI_INVALID_PARAMETER;
}
+ } else if ((Attributes & EFI_VARIABLE_ATTRIBUTES_MASK) == EFI_VARIABLE_NON_VOLATILE) {
+ //
+ // Only EFI_VARIABLE_NON_VOLATILE attribute is invalid
+ //
+ return EFI_INVALID_PARAMETER;
} else if ((Attributes & VARIABLE_ATTRIBUTE_AT_AW) != 0) {
if (!mVariableModuleGlobal->VariableGlobal.AuthSupport) {
//
@@ -3142,6 +3151,11 @@ VariableServiceQueryVariableInfo (
// Make sure the Attributes combination is supported by the platform.
//
return EFI_UNSUPPORTED;
+ } else if ((Attributes & EFI_VARIABLE_ATTRIBUTES_MASK) == EFI_VARIABLE_NON_VOLATILE) {
+ //
+ // Only EFI_VARIABLE_NON_VOLATILE attribute is invalid
+ //
+ return EFI_INVALID_PARAMETER;
} else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {
//
// Make sure if runtime bit is set, boot service bit is set also.