Blame SOURCES/ovmf-MdeModulePkg-Variable-Fix-Timestamp-zeroing-issue-on.patch

3c2ede
From 0afba771bf42a9793e86bc565f23a8ca99d53dbb Mon Sep 17 00:00:00 2001
3c2ede
From: Philippe Mathieu-Daude <philmd@redhat.com>
3c2ede
Date: Wed, 13 Feb 2019 09:50:44 +0100
3c2ede
Subject: [PATCH 01/13] MdeModulePkg Variable: Fix Timestamp zeroing issue on
3c2ede
 APPEND_WRITE
3c2ede
3c2ede
Message-id: <20190213085050.20766-2-philmd@redhat.com>
3c2ede
Patchwork-id: 84478
3c2ede
O-Subject:  [RHEL-7.7 ovmf PATCH v3 1/7] MdeModulePkg Variable: Fix Timestamp
3c2ede
	zeroing issue on APPEND_WRITE
3c2ede
Bugzilla: 1666586
3c2ede
Acked-by: Laszlo Ersek <lersek@redhat.com>
3c2ede
Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
3c2ede
3c2ede
From: Laszlo Ersek <lersek@redhat.com>
3c2ede
3c2ede
From: Star Zeng <star.zeng@intel.com>
3c2ede
3c2ede
--v-- RHEL7 note start --v--
3c2ede
3c2ede
This patch fixes CVE-2018-3613. Unfortunately, the upstream subject line
3c2ede
does not include the CVE number. I've decided to stick with the upstream
3c2ede
subject verbatim in the backport, so we can more easily drop this patch at
3c2ede
the next rebase. On the upstream list, I did complain loudly, so there's
3c2ede
hope the next CVE fix will advertise the CVE number in the subject.
3c2ede
3c2ede
In practice, the vulnerability is difficult to exploit. Please refer to
3c2ede
the following messages in the upstream discussion:
3c2ede
3c2ede
  https://lists.01.org/pipermail/edk2-devel/2018-October/031103.html
3c2ede
  https://lists.01.org/pipermail/edk2-devel/2018-October/031140.html
3c2ede
3c2ede
--^-- RHEL7 note end --^--
3c2ede
3c2ede
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=415
3c2ede
3c2ede
When SetVariable() to a time based auth variable with APPEND_WRITE
3c2ede
attribute, and if the EFI_VARIABLE_AUTHENTICATION_2.TimeStamp in
3c2ede
the input Data is earlier than current value, it will cause timestamp
3c2ede
zeroing.
3c2ede
3c2ede
This issue may bring time based auth variable downgrade problem.
3c2ede
For example:
3c2ede
A vendor released three certs at 2014, 2015, and 2016, and system
3c2ede
integrated the 2016 cert. User can SetVariable() with 2015 cert and
3c2ede
APPEND_WRITE attribute to cause timestamp zeroing first, then
3c2ede
SetVariable() with 2014 cert to downgrade the cert.
3c2ede
3c2ede
This patch fixes this issue.
3c2ede
3c2ede
Cc: Jiewen Yao <jiewen.yao@intel.com>
3c2ede
Cc: Chao Zhang <chao.b.zhang@intel.com>
3c2ede
Cc: Jian J Wang <jian.j.wang@intel.com>
3c2ede
Contributed-under: TianoCore Contribution Agreement 1.1
3c2ede
Signed-off-by: Star Zeng <star.zeng@intel.com>
3c2ede
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
3c2ede
(cherry picked from commit b7dc8888f31402f410c53242839271ba3b94b619)
3c2ede
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
3c2ede
(cherry picked from commit 3b8ff18ad4ac1af740a979ad27fb83dbbdca70ef)
3c2ede
Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com>
3c2ede
---
3c2ede
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 2 ++
3c2ede
 1 file changed, 2 insertions(+)
3c2ede
3c2ede
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
3c2ede
index 6caf603..60439b5 100644
3c2ede
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
3c2ede
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
3c2ede
@@ -2460,6 +2460,8 @@ UpdateVariable (
3c2ede
         if (Variable->CurrPtr != NULL) {
3c2ede
           if (VariableCompareTimeStampInternal (&(((AUTHENTICATED_VARIABLE_HEADER *) CacheVariable->CurrPtr)->TimeStamp), TimeStamp)) {
3c2ede
             CopyMem (&AuthVariable->TimeStamp, TimeStamp, sizeof (EFI_TIME));
3c2ede
+          } else {
3c2ede
+            CopyMem (&AuthVariable->TimeStamp, &(((AUTHENTICATED_VARIABLE_HEADER *) CacheVariable->CurrPtr)->TimeStamp), sizeof (EFI_TIME));
3c2ede
           }
3c2ede
         }
3c2ede
       }
3c2ede
-- 
3c2ede
1.8.3.1
3c2ede