]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Variable/RuntimeDxe: delete & lock MOR in the absence of SMM
authorLaszlo Ersek <lersek@redhat.com>
Tue, 10 Oct 2017 11:44:16 +0000 (13:44 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Wed, 25 Oct 2017 12:06:15 +0000 (14:06 +0200)
VariableRuntimeDxe deletes and locks the MorLock variable in
MorLockInit(), with the argument that any protection provided by MorLock
can be circumvented if MorLock can be overwritten by unprivileged code
(i.e., outside of SMM).

Extend the argument and the logic to the MOR variable, which is supposed
to be protected by MorLock. Pass Attributes=0 when deleting MorLock and
MOR both.

This change was suggested by Star; it is inspired by earlier VariableSmm
commit fda8f631edbb ("MdeModulePkg/Variable/RuntimeDxe: delete and lock
OS-created MOR variable", 2017-10-03).

Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Suggested-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockDxe.c

index 7142e2da2073feb8bfd91e91e38ae28897ae5e41..fb4e13ab25a78c809f9f85c470cb7b4e4308c736 100644 (file)
@@ -78,15 +78,39 @@ MorLockInit (
   VariableServiceSetVariable (\r
     MEMORY_OVERWRITE_REQUEST_CONTROL_LOCK_NAME,\r
     &gEfiMemoryOverwriteRequestControlLockGuid,\r
-    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-    0,\r
-    NULL\r
+    0,                                          // Attributes\r
+    0,                                          // DataSize\r
+    NULL                                        // Data\r
     );\r
 \r
   //\r
   // Need set this variable to be read-only to prevent other module set it.\r
   //\r
   VariableLockRequestToLock (&mVariableLock, MEMORY_OVERWRITE_REQUEST_CONTROL_LOCK_NAME, &gEfiMemoryOverwriteRequestControlLockGuid);\r
+\r
+  //\r
+  // The MOR variable can effectively improve platform security only when the\r
+  // MorLock variable protects the MOR variable. In turn MorLock cannot be made\r
+  // secure without SMM support in the platform firmware (see above).\r
+  //\r
+  // Thus, delete the MOR variable, should it exist for any reason (some OSes\r
+  // are known to create MOR unintentionally, in an attempt to set it), then\r
+  // also lock the MOR variable, in order to prevent other modules from\r
+  // creating it.\r
+  //\r
+  VariableServiceSetVariable (\r
+    MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,\r
+    &gEfiMemoryOverwriteControlDataGuid,\r
+    0,                                      // Attributes\r
+    0,                                      // DataSize\r
+    NULL                                    // Data\r
+    );\r
+  VariableLockRequestToLock (\r
+    &mVariableLock,\r
+    MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,\r
+    &gEfiMemoryOverwriteControlDataGuid\r
+    );\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r