summaryrefslogtreecommitdiff
path: root/SecurityPkg
diff options
context:
space:
mode:
Diffstat (limited to 'SecurityPkg')
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
index 28d026a0a..71cd460e0 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
@@ -16,7 +16,7 @@
VariableServiceSetVariable() should also check authenticate data to avoid buffer overflow,
integer overflow. It should also check attribute to avoid authentication bypass.
-Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2014, 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
@@ -1522,8 +1522,13 @@ VariableGetBestLanguage (
@param[in] DataSize Size of data. 0 means delete.
+ @retval EFI_SUCCESS The update operation is successful or ignored.
+ @retval EFI_WRITE_PROTECTED Update PlatformLangCodes/LangCodes at runtime.
+ @retval EFI_OUT_OF_RESOURCES No enough variable space to do the update operation.
+ @retval Others Other errors happened during the update operation.
+
**/
-VOID
+EFI_STATUS
AutoUpdateLangVariable (
IN CHAR16 *VariableName,
IN VOID *Data,
@@ -1542,7 +1547,7 @@ AutoUpdateLangVariable (
// Don't do updates for delete operation
//
if (DataSize == 0) {
- return;
+ return EFI_SUCCESS;
}
SetLanguageCodes = FALSE;
@@ -1552,7 +1557,7 @@ AutoUpdateLangVariable (
// PlatformLangCodes is a volatile variable, so it can not be updated at runtime.
//
if (AtRuntime ()) {
- return;
+ return EFI_WRITE_PROTECTED;
}
SetLanguageCodes = TRUE;
@@ -1582,7 +1587,7 @@ AutoUpdateLangVariable (
// LangCodes is a volatile variable, so it can not be updated at runtime.
//
if (AtRuntime ()) {
- return;
+ return EFI_WRITE_PROTECTED;
}
SetLanguageCodes = TRUE;
@@ -1626,11 +1631,13 @@ AutoUpdateLangVariable (
//
// Neither PlatformLang nor Lang is set, directly return
//
- return;
+ return EFI_SUCCESS;
}
}
}
+ Status = EFI_SUCCESS;
+
//
// According to UEFI spec, "Lang" and "PlatformLang" is NV|BS|RT attributions.
//
@@ -1664,9 +1671,7 @@ AutoUpdateLangVariable (
Status = UpdateVariable (EFI_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid, BestLang,
ISO_639_2_ENTRY_SIZE + 1, Attributes, 0, 0, &Variable, NULL);
- DEBUG ((EFI_D_INFO, "Variable Driver Auto Update PlatformLang, PlatformLang:%a, Lang:%a\n", BestPlatformLang, BestLang));
-
- ASSERT_EFI_ERROR(Status);
+ DEBUG ((EFI_D_INFO, "Variable Driver Auto Update PlatformLang, PlatformLang:%a, Lang:%a Status: %r\n", BestPlatformLang, BestLang, Status));
}
}
@@ -1698,11 +1703,12 @@ AutoUpdateLangVariable (
Status = UpdateVariable (EFI_PLATFORM_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid, BestPlatformLang,
AsciiStrSize (BestPlatformLang), Attributes, 0, 0, &Variable, NULL);
- DEBUG ((EFI_D_INFO, "Variable Driver Auto Update Lang, Lang:%a, PlatformLang:%a\n", BestLang, BestPlatformLang));
- ASSERT_EFI_ERROR (Status);
+ DEBUG ((EFI_D_INFO, "Variable Driver Auto Update Lang, Lang:%a, PlatformLang:%a Status: %r\n", BestLang, BestPlatformLang, Status));
}
}
}
+
+ return Status;
}
/**
@@ -2990,7 +2996,14 @@ VariableServiceSetVariable (
//
// Hook the operation of setting PlatformLangCodes/PlatformLang and LangCodes/Lang.
//
- AutoUpdateLangVariable (VariableName, Data, DataSize);
+ Status = AutoUpdateLangVariable (VariableName, Data, DataSize);
+ if (EFI_ERROR (Status)) {
+ //
+ // The auto update operation failed, directly return to avoid inconsistency between PlatformLang and Lang.
+ //
+ goto Done;
+ }
+
//
// Process PK, KEK, Sigdb seperately.
//