uswsusp: Disable when the kernel is locked down
authorMatthew Garrett <mjg59@srcf.ucam.org>
Wed, 8 Nov 2017 15:11:33 +0000 (15:11 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 19 Apr 2018 10:13:03 +0000 (11:13 +0100)
uswsusp allows a user process to dump and then restore kernel state, which
makes it possible to modify the running kernel.  Disable this if the kernel
is locked down.

Signed-off-by: Matthew Garrett <mjg59@srcf.ucam.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: "Lee, Chun-Yi" <jlee@suse.com>
Reviewed-by: James Morris <james.l.morris@oracle.com>
cc: linux-pm@vger.kernel.org

Gbp-Pq: Topic features/all/lockdown
Gbp-Pq: Name 0010-uswsusp-Disable-when-the-kernel-is-locked-down.patch

kernel/power/user.c

index 22df9f7ff672425f1200c421eceff5a41c220ff2..678ade9decfe8e78a300d3f5b4989c26bb87a947 100644 (file)
@@ -52,6 +52,9 @@ static int snapshot_open(struct inode *inode, struct file *filp)
        if (!hibernation_available())
                return -EPERM;
 
+       if (kernel_is_locked_down("/dev/snapshot"))
+               return -EPERM;
+
        lock_system_sleep();
 
        if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {