]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/QemuFwCfgDxeLib: SEV: zero FW_CFG_DMA_ACCESS before decrypting it
authorLaszlo Ersek <lersek@redhat.com>
Mon, 28 Aug 2017 09:48:00 +0000 (11:48 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Tue, 29 Aug 2017 20:44:33 +0000 (22:44 +0200)
There's a small window between

- AllocFwCfgDmaAccessBuffer() mapping the new FW_CFG_DMA_ACCESS object for
  common buffer operation (i.e., decrypting it), and

- InternalQemuFwCfgDmaBytes() setting the fields of the object.

In this window, earlier garbage in the object is "leaked" to the
hypervisor. So zero the object before we decrypt it.

(This commit message references AMD SEV directly, because QemuFwCfgDxeLib
is not *generally* enabled for IOMMU operation just yet, unlike our goal
for the virtio infrastructure. Instead, QemuFwCfgDxeLib uses
MemEncryptSevLib explicitly to detect SEV, and then relies on IOMMU
protocol behavior that is specific to SEV. At this point, this is by
design.)

Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c

index 8b98208591e6191b52b171c43dcf9f200073e876..22077851a40cdc675ef1644f5bec8e36ced1d62e 100644 (file)
@@ -20,6 +20,7 @@
 #include <Protocol/IoMmu.h>\r
 \r
 #include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
 #include <Library/IoLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/QemuFwCfgLib.h>\r
@@ -188,6 +189,12 @@ AllocFwCfgDmaAccessBuffer (
     CpuDeadLoop ();\r
   }\r
 \r
+  //\r
+  // Avoid exposing stale data even temporarily: zero the area before mapping\r
+  // it.\r
+  //\r
+  ZeroMem (HostAddress, Size);\r
+\r
   //\r
   // Map the host buffer with BusMasterCommonBuffer64\r
   //\r