Revision: 15349
http://sourceforge.net/p/edk2/code/15349
Author: vanjeff
Date: 2014-03-20 03:30:35 +0000 (Thu, 20 Mar 2014)
Log Message:
-----------
Sync patch r15340 from main trunk.
MdeModulePkg/SecurityPkg Variable: Return error status to avoid inconsistency
between PlatformLang and Lang.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <[email protected]>
Revision Links:
--------------
http://sourceforge.net/p/edk2/code/15340
Modified Paths:
--------------
branches/UDK2010.SR1/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
branches/UDK2010.SR1/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
Modified:
branches/UDK2010.SR1/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
===================================================================
--- branches/UDK2010.SR1/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
2014-03-20 03:25:45 UTC (rev 15348)
+++ branches/UDK2010.SR1/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
2014-03-20 03:30:35 UTC (rev 15349)
@@ -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
@@ -1211,8 +1211,13 @@
@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,
@@ -1231,7 +1236,7 @@
// Don't do updates for delete operation
//
if (DataSize == 0) {
- return;
+ return EFI_SUCCESS;
}
SetLanguageCodes = FALSE;
@@ -1241,7 +1246,7 @@
// PlatformLangCodes is a volatile variable, so it can not be updated at
runtime.
//
if (AtRuntime ()) {
- return;
+ return EFI_WRITE_PROTECTED;
}
SetLanguageCodes = TRUE;
@@ -1271,7 +1276,7 @@
// LangCodes is a volatile variable, so it can not be updated at runtime.
//
if (AtRuntime ()) {
- return;
+ return EFI_WRITE_PROTECTED;
}
SetLanguageCodes = TRUE;
@@ -1315,11 +1320,13 @@
//
// 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.
//
@@ -1353,9 +1360,7 @@
Status = UpdateVariable (L"Lang", &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));
}
}
@@ -1387,11 +1392,12 @@
Status = UpdateVariable (L"PlatformLang", &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;
}
/**
@@ -2366,7 +2372,13 @@
//
// 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);
Modified:
branches/UDK2010.SR1/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
===================================================================
---
branches/UDK2010.SR1/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
2014-03-20 03:25:45 UTC (rev 15348)
+++
branches/UDK2010.SR1/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
2014-03-20 03:30:35 UTC (rev 15349)
@@ -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
@@ -1462,8 +1462,13 @@
@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,
@@ -1482,7 +1487,7 @@
// Don't do updates for delete operation
//
if (DataSize == 0) {
- return;
+ return EFI_SUCCESS;
}
SetLanguageCodes = FALSE;
@@ -1492,7 +1497,7 @@
// PlatformLangCodes is a volatile variable, so it can not be updated at
runtime.
//
if (AtRuntime ()) {
- return;
+ return EFI_WRITE_PROTECTED;
}
SetLanguageCodes = TRUE;
@@ -1522,7 +1527,7 @@
// LangCodes is a volatile variable, so it can not be updated at runtime.
//
if (AtRuntime ()) {
- return;
+ return EFI_WRITE_PROTECTED;
}
SetLanguageCodes = TRUE;
@@ -1566,11 +1571,13 @@
//
// 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.
//
@@ -1604,9 +1611,7 @@
Status = UpdateVariable (L"Lang", &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));
}
}
@@ -1638,11 +1643,12 @@
Status = UpdateVariable (L"PlatformLang", &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;
}
/**
@@ -2850,7 +2856,14 @@
//
// 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.
//
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits