mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-28 16:14:04 +02:00
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
This commit is contained in:
parent
25da08c8b2
commit
9bc5dabb10
@ -3,7 +3,7 @@
|
|||||||
The common variable operation routines shared by DXE_RUNTIME variable
|
The common variable operation routines shared by DXE_RUNTIME variable
|
||||||
module and DXE_SMM variable module.
|
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
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
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.
|
@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 (
|
AutoUpdateLangVariable (
|
||||||
IN CHAR16 *VariableName,
|
IN CHAR16 *VariableName,
|
||||||
IN VOID *Data,
|
IN VOID *Data,
|
||||||
@ -1292,7 +1297,7 @@ AutoUpdateLangVariable (
|
|||||||
// Don't do updates for delete operation
|
// Don't do updates for delete operation
|
||||||
//
|
//
|
||||||
if (DataSize == 0) {
|
if (DataSize == 0) {
|
||||||
return;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLanguageCodes = FALSE;
|
SetLanguageCodes = FALSE;
|
||||||
@ -1302,7 +1307,7 @@ AutoUpdateLangVariable (
|
|||||||
// PlatformLangCodes is a volatile variable, so it can not be updated at runtime.
|
// PlatformLangCodes is a volatile variable, so it can not be updated at runtime.
|
||||||
//
|
//
|
||||||
if (AtRuntime ()) {
|
if (AtRuntime ()) {
|
||||||
return;
|
return EFI_WRITE_PROTECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLanguageCodes = TRUE;
|
SetLanguageCodes = TRUE;
|
||||||
@ -1332,7 +1337,7 @@ AutoUpdateLangVariable (
|
|||||||
// LangCodes is a volatile variable, so it can not be updated at runtime.
|
// LangCodes is a volatile variable, so it can not be updated at runtime.
|
||||||
//
|
//
|
||||||
if (AtRuntime ()) {
|
if (AtRuntime ()) {
|
||||||
return;
|
return EFI_WRITE_PROTECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLanguageCodes = TRUE;
|
SetLanguageCodes = TRUE;
|
||||||
@ -1376,11 +1381,13 @@ AutoUpdateLangVariable (
|
|||||||
//
|
//
|
||||||
// Neither PlatformLang nor Lang is set, directly return
|
// 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.
|
// 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,
|
Status = UpdateVariable (EFI_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid, BestLang,
|
||||||
ISO_639_2_ENTRY_SIZE + 1, Attributes, &Variable);
|
ISO_639_2_ENTRY_SIZE + 1, Attributes, &Variable);
|
||||||
|
|
||||||
DEBUG ((EFI_D_INFO, "Variable Driver Auto Update PlatformLang, PlatformLang:%a, Lang:%a\n", BestPlatformLang, BestLang));
|
DEBUG ((EFI_D_INFO, "Variable Driver Auto Update PlatformLang, PlatformLang:%a, Lang:%a: Status: %r\n", BestPlatformLang, BestLang, Status));
|
||||||
|
|
||||||
ASSERT_EFI_ERROR(Status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1448,11 +1453,12 @@ AutoUpdateLangVariable (
|
|||||||
Status = UpdateVariable (EFI_PLATFORM_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid, BestPlatformLang,
|
Status = UpdateVariable (EFI_PLATFORM_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid, BestPlatformLang,
|
||||||
AsciiStrSize (BestPlatformLang), Attributes, &Variable);
|
AsciiStrSize (BestPlatformLang), Attributes, &Variable);
|
||||||
|
|
||||||
DEBUG ((EFI_D_INFO, "Variable Driver Auto Update Lang, Lang:%a, PlatformLang:%a\n", BestLang, BestPlatformLang));
|
DEBUG ((EFI_D_INFO, "Variable Driver Auto Update Lang, Lang:%a, PlatformLang:%a Status: %r\n", BestLang, BestPlatformLang, Status));
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2489,7 +2495,13 @@ VariableServiceSetVariable (
|
|||||||
//
|
//
|
||||||
// Hook the operation of setting PlatformLangCodes/PlatformLang and LangCodes/Lang.
|
// 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);
|
Status = UpdateVariable (VariableName, VendorGuid, Data, DataSize, Attributes, &Variable);
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
VariableServiceSetVariable() should also check authenticate data to avoid buffer overflow,
|
VariableServiceSetVariable() should also check authenticate data to avoid buffer overflow,
|
||||||
integer overflow. It should also check attribute to avoid authentication bypass.
|
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
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
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.
|
@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 (
|
AutoUpdateLangVariable (
|
||||||
IN CHAR16 *VariableName,
|
IN CHAR16 *VariableName,
|
||||||
IN VOID *Data,
|
IN VOID *Data,
|
||||||
@ -1542,7 +1547,7 @@ AutoUpdateLangVariable (
|
|||||||
// Don't do updates for delete operation
|
// Don't do updates for delete operation
|
||||||
//
|
//
|
||||||
if (DataSize == 0) {
|
if (DataSize == 0) {
|
||||||
return;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLanguageCodes = FALSE;
|
SetLanguageCodes = FALSE;
|
||||||
@ -1552,7 +1557,7 @@ AutoUpdateLangVariable (
|
|||||||
// PlatformLangCodes is a volatile variable, so it can not be updated at runtime.
|
// PlatformLangCodes is a volatile variable, so it can not be updated at runtime.
|
||||||
//
|
//
|
||||||
if (AtRuntime ()) {
|
if (AtRuntime ()) {
|
||||||
return;
|
return EFI_WRITE_PROTECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLanguageCodes = TRUE;
|
SetLanguageCodes = TRUE;
|
||||||
@ -1582,7 +1587,7 @@ AutoUpdateLangVariable (
|
|||||||
// LangCodes is a volatile variable, so it can not be updated at runtime.
|
// LangCodes is a volatile variable, so it can not be updated at runtime.
|
||||||
//
|
//
|
||||||
if (AtRuntime ()) {
|
if (AtRuntime ()) {
|
||||||
return;
|
return EFI_WRITE_PROTECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLanguageCodes = TRUE;
|
SetLanguageCodes = TRUE;
|
||||||
@ -1626,11 +1631,13 @@ AutoUpdateLangVariable (
|
|||||||
//
|
//
|
||||||
// Neither PlatformLang nor Lang is set, directly return
|
// 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.
|
// 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,
|
Status = UpdateVariable (EFI_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid, BestLang,
|
||||||
ISO_639_2_ENTRY_SIZE + 1, Attributes, 0, 0, &Variable, NULL);
|
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));
|
DEBUG ((EFI_D_INFO, "Variable Driver Auto Update PlatformLang, PlatformLang:%a, Lang:%a Status: %r\n", BestPlatformLang, BestLang, Status));
|
||||||
|
|
||||||
ASSERT_EFI_ERROR(Status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1698,11 +1703,12 @@ AutoUpdateLangVariable (
|
|||||||
Status = UpdateVariable (EFI_PLATFORM_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid, BestPlatformLang,
|
Status = UpdateVariable (EFI_PLATFORM_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid, BestPlatformLang,
|
||||||
AsciiStrSize (BestPlatformLang), Attributes, 0, 0, &Variable, NULL);
|
AsciiStrSize (BestPlatformLang), Attributes, 0, 0, &Variable, NULL);
|
||||||
|
|
||||||
DEBUG ((EFI_D_INFO, "Variable Driver Auto Update Lang, Lang:%a, PlatformLang:%a\n", BestLang, BestPlatformLang));
|
DEBUG ((EFI_D_INFO, "Variable Driver Auto Update Lang, Lang:%a, PlatformLang:%a Status: %r\n", BestLang, BestPlatformLang, Status));
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2990,7 +2996,14 @@ VariableServiceSetVariable (
|
|||||||
//
|
//
|
||||||
// Hook the operation of setting PlatformLangCodes/PlatformLang and LangCodes/Lang.
|
// 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.
|
// Process PK, KEK, Sigdb seperately.
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user