summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2014-03-20 02:07:48 +0000
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2014-03-20 02:07:48 +0000
commit9bc5dabb10a29de5759de7f5ec3fe55307c5e226 (patch)
tree22ea89a44cd85c7cb455e7d456b7188289ff92c8
parent25da08c8b2a73b375f57652104cfdbd0db82d31e (diff)
downloadedk2-9bc5dabb10a29de5759de7f5ec3fe55307c5e226.tar.gz
edk2-9bc5dabb10a29de5759de7f5ec3fe55307c5e226.tar.bz2
edk2-9bc5dabb10a29de5759de7f5ec3fe55307c5e226.zip
MdeModulePkg/SecurityPkg Variable: Return error status to avoid inconsistency between PlatformLang and Lang.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15340 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c38
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c37
2 files changed, 50 insertions, 25 deletions
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index c66eb87506..5f128e9d61 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -3,7 +3,7 @@
The common variable operation routines shared by DXE_RUNTIME variable
module and DXE_SMM variable module.
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -1272,8 +1272,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,
@@ -1292,7 +1297,7 @@ AutoUpdateLangVariable (
// Don't do updates for delete operation
//
if (DataSize == 0) {
- return;
+ return EFI_SUCCESS;
}
SetLanguageCodes = FALSE;
@@ -1302,7 +1307,7 @@ AutoUpdateLangVariable (
// PlatformLangCodes is a volatile variable, so it can not be updated at runtime.
//
if (AtRuntime ()) {
- return;
+ return EFI_WRITE_PROTECTED;
}
SetLanguageCodes = TRUE;
@@ -1332,7 +1337,7 @@ AutoUpdateLangVariable (
// LangCodes is a volatile variable, so it can not be updated at runtime.
//
if (AtRuntime ()) {
- return;
+ return EFI_WRITE_PROTECTED;
}
SetLanguageCodes = TRUE;
@@ -1376,11 +1381,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.
//
@@ -1414,9 +1421,7 @@ AutoUpdateLangVariable (
Status = UpdateVariable (EFI_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid, BestLang,
ISO_639_2_ENTRY_SIZE + 1, Attributes, &Variable);
- 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));
}
}
@@ -1448,11 +1453,12 @@ AutoUpdateLangVariable (
Status = UpdateVariable (EFI_PLATFORM_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid, BestPlatformLang,
AsciiStrSize (BestPlatformLang), Attributes, &Variable);
- 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;
}
/**
@@ -2489,7 +2495,13 @@ 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;
+ }
Status = UpdateVariable (VariableName, VendorGuid, Data, DataSize, Attributes, &Variable);
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
index 28d026a0a8..71cd460e0c 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.
//