asus-wmi: Restrict debugfs interface when securelevel is set
authorMatthew Garrett <mjg59@srcf.ucam.org>
Fri, 9 Mar 2012 13:46:50 +0000 (08:46 -0500)
committerYves-Alexis Perez <corsac@debian.org>
Fri, 9 Feb 2018 12:58:52 +0000 (12:58 +0000)
We have no way of validating what all of the Asus WMI methods do on a
given machine, and there's a risk that some will allow hardware state to
be manipulated in such a way that arbitrary code can be executed in the
kernel. Prevent that if securelevel is set.

Signed-off-by: Matthew Garrett <mjg59@srcf.ucam.org>
Gbp-Pq: Topic features/all/securelevel
Gbp-Pq: Name asus-wmi-restrict-debugfs-interface-when-securelevel.patch

drivers/platform/x86/asus-wmi.c

index 8499d3ae4257b68fcbe276e9467ffe61e5a581b8..39fb5470bfd57b90e585eea5418e758d9b415d68 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/seq_file.h>
 #include <linux/platform_device.h>
 #include <linux/thermal.h>
+#include <linux/security.h>
 #include <linux/acpi.h>
 #include <linux/dmi.h>
 #include <acpi/video.h>
@@ -1900,6 +1901,9 @@ static int show_dsts(struct seq_file *m, void *data)
        int err;
        u32 retval = -1;
 
+       if (get_securelevel() > 0)
+               return -EPERM;
+
        err = asus_wmi_get_devstate(asus, asus->debug.dev_id, &retval);
 
        if (err < 0)
@@ -1916,6 +1920,9 @@ static int show_devs(struct seq_file *m, void *data)
        int err;
        u32 retval = -1;
 
+       if (get_securelevel() > 0)
+               return -EPERM;
+
        err = asus_wmi_set_devstate(asus->debug.dev_id, asus->debug.ctrl_param,
                                    &retval);
 
@@ -1940,6 +1947,9 @@ static int show_call(struct seq_file *m, void *data)
        union acpi_object *obj;
        acpi_status status;
 
+       if (get_securelevel() > 0)
+               return -EPERM;
+
        status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID,
                                     1, asus->debug.method_id,
                                     &input, &output);