summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2017-02-28 14:01:47 +0800
committerStar Zeng <star.zeng@intel.com>2018-10-17 11:30:42 +0800
commit5c693e581e6ab2c8e9daac170616d867272399d9 (patch)
treebbefd2899c6b151f729787922b70f37901f34aec
parentacaa5d7382e3cd5a991b61cafb2c4f6807e2c07e (diff)
downloadedk2-5c693e581e6ab2c8e9daac170616d867272399d9.tar.gz
edk2-5c693e581e6ab2c8e9daac170616d867272399d9.tar.bz2
edk2-5c693e581e6ab2c8e9daac170616d867272399d9.zip
MdeModulePkg Variable: Fix Timestamp zeroing issue on APPEND_WRITE
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=415 When SetVariable() to a time based auth variable with APPEND_WRITE attribute, and if the EFI_VARIABLE_AUTHENTICATION_2.TimeStamp in the input Data is earlier than current value, it will cause timestamp zeroing. This issue may bring time based auth variable downgrade problem. For example: A vendor released three certs at 2014, 2015, and 2016, and system integrated the 2016 cert. User can SetVariable() with 2015 cert and APPEND_WRITE attribute to cause timestamp zeroing first, then SetVariable() with 2014 cert to downgrade the cert. This patch fixes this issue. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Chao Zhang <chao.b.zhang@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> (cherry picked from commit b7dc8888f31402f410c53242839271ba3b94b619)
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
index 0a325de165..c5ca70b714 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
@@ -2508,6 +2508,8 @@ UpdateVariable (
if (Variable->CurrPtr != NULL) {
if (VariableCompareTimeStampInternal (&(((AUTHENTICATED_VARIABLE_HEADER *) CacheVariable->CurrPtr)->TimeStamp), TimeStamp)) {
CopyMem (&AuthVariable->TimeStamp, TimeStamp, sizeof (EFI_TIME));
+ } else {
+ CopyMem (&AuthVariable->TimeStamp, &(((AUTHENTICATED_VARIABLE_HEADER *) CacheVariable->CurrPtr)->TimeStamp), sizeof (EFI_TIME));
}
}
}