Enable cold boot attack mitigation
authorMatthew Garrett <mjg59@coreos.com>
Tue, 12 Jan 2016 20:51:27 +0000 (12:51 -0800)
committerYves-Alexis Perez <corsac@debian.org>
Wed, 21 Feb 2018 15:29:03 +0000 (15:29 +0000)
Gbp-Pq: Topic features/all/securelevel
Gbp-Pq: Name enable-cold-boot-attack-mitigation.patch

arch/x86/boot/compressed/eboot.c

index e042f00cd9f7b5adbf373c1ce0fac494de02ca60..715ccf95a430e58b22debb6409f69af6c61b41c9 100644 (file)
@@ -711,6 +711,22 @@ void setup_graphics(struct boot_params *boot_params)
        }
 }
 
+#define MEMORY_ONLY_RESET_CONTROL_GUID \
+       EFI_GUID (0xe20939be, 0x32d4, 0x41be, 0xa1, 0x50, 0x89, 0x7f, 0x85, 0xd4, 0x98, 0x29)
+
+static void enable_reset_attack_mitigation(void)
+{
+       u8 val = 1;
+       efi_guid_t var_guid = MEMORY_ONLY_RESET_CONTROL_GUID;
+
+       /* Ignore the return value here - there's not really a lot we can do */
+       efi_early->call((unsigned long)sys_table->runtime->set_variable,
+                       L"MemoryOverwriteRequestControl", &var_guid,
+                       EFI_VARIABLE_NON_VOLATILE |
+                       EFI_VARIABLE_BOOTSERVICE_ACCESS |
+                       EFI_VARIABLE_RUNTIME_ACCESS, sizeof(val), val);
+}
+
 static int get_secure_boot(void)
 {
        u8 sb, setup, moksbstate;
@@ -1144,6 +1160,12 @@ struct boot_params *efi_main(struct efi_config *c,
        else
                setup_boot_services32(efi_early);
 
+       /*
+        * Ask the firmware to clear memory if we don't have a clean
+        * shutdown
+        */
+       enable_reset_attack_mitigation();
+
        sanitize_boot_params(boot_params);
 
        boot_params->secure_boot = get_secure_boot();