acpi: Limit access to custom_method if securelevel is set
authorMatthew Garrett <mjg59@srcf.ucam.org>
Fri, 9 Mar 2012 13:39:37 +0000 (08:39 -0500)
committerYves-Alexis Perez <corsac@debian.org>
Fri, 9 Feb 2018 12:58:52 +0000 (12:58 +0000)
custom_method effectively allows arbitrary access to system memory, making
it possible for an attacker to modify the kernel at runtime. Prevent this
if securelevel has been set.

Signed-off-by: Matthew Garrett <mjg59@srcf.ucam.org>
Gbp-Pq: Topic features/all/securelevel
Gbp-Pq: Name acpi-limit-access-to-custom_method-if-securelevel-is.patch

drivers/acpi/custom_method.c

index c68e72414a67a9b00231b095335945d5cdd2f31e..359f45d54543ae8e64082e5a918056e480d1c881 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/uaccess.h>
 #include <linux/debugfs.h>
 #include <linux/acpi.h>
+#include <linux/security.h>
 
 #include "internal.h"
 
@@ -29,6 +30,9 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
        struct acpi_table_header table;
        acpi_status status;
 
+       if (get_securelevel() > 0)
+               return -EPERM;
+
        if (!(*ppos)) {
                /* parse the table header to get the table length */
                if (count <= sizeof(struct acpi_table_header))