acpi: Disable ACPI table override if securelevel is set
authorLinn Crosetto <linn@hpe.com>
Fri, 4 Mar 2016 23:08:24 +0000 (16:08 -0700)
committerYves-Alexis Perez <corsac@debian.org>
Fri, 9 Feb 2018 12:58:52 +0000 (12:58 +0000)
From the kernel documentation (initrd_table_override.txt):

  If the ACPI_INITRD_TABLE_OVERRIDE compile option is true, it is possible
  to override nearly any ACPI table provided by the BIOS with an
  instrumented, modified one.

When securelevel is set, the kernel should disallow any unauthenticated
changes to kernel space. ACPI tables contain code invoked by the kernel, so
do not allow ACPI tables to be overridden if securelevel is set.

Signed-off-by: Linn Crosetto <linn@hpe.com>
[bwh: Forward-ported to 4.7: ACPI override code moved to drivers/acpi/tables.c]
[bwh: Forward-ported to 4.9: adjust context]

Gbp-Pq: Topic features/all/securelevel
Gbp-Pq: Name acpi-disable-acpi-table-override-if-securelevel-is-s.patch

arch/x86/kernel/setup.c
drivers/acpi/tables.c

index ecaa01d77b2174a0ecfcc6fd9672b3ee5d43a1a0..1500d2fb9b3d243404a919d04ae81503109da052 100644 (file)
@@ -1167,6 +1167,12 @@ void __init setup_arch(char **cmdline_p)
        /* Allocate bigger log buffer */
        setup_log_buf(1);
 
+#ifdef CONFIG_EFI_SECURE_BOOT_SECURELEVEL
+       if (boot_params.secure_boot) {
+               set_securelevel(1);
+       }
+#endif
+
        reserve_initrd();
 
        acpi_table_upgrade();
@@ -1175,12 +1181,6 @@ void __init setup_arch(char **cmdline_p)
 
        io_delay_init();
 
-#ifdef CONFIG_EFI_SECURE_BOOT_SECURELEVEL
-       if (boot_params.secure_boot) {
-               set_securelevel(1);
-       }
-#endif
-
        /*
         * Parse the ACPI tables for possible boot-time SMP configuration.
         */
index cdd56c4657e05ff38ed8e11da59d0c37a91326d6..1d493f12eea629035f8bafc8b977d768a50610db 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/earlycpio.h>
 #include <linux/memblock.h>
 #include <linux/initrd.h>
+#include <linux/security.h>
 #include "internal.h"
 
 #ifdef CONFIG_ACPI_CUSTOM_DSDT
@@ -545,6 +546,12 @@ void __init acpi_table_upgrade(void)
        if (table_nr == 0)
                return;
 
+       if (get_securelevel() > 0) {
+               pr_notice(PREFIX
+                       "securelevel enabled, ignoring table override\n");
+               return;
+       }
+
        acpi_tables_addr =
                memblock_find_in_range(0, ACPI_TABLE_UPGRADE_MAX_PHYS,
                                       all_tables_size, PAGE_SIZE);