68d0d6
Bugzilla: N/A
68d0d6
Upstream-status: Fedora mustard
68d0d6
Josh Boyer d7ee6f
From ffe1ee94d526900ce1e5191cdd38934477dd209a Mon Sep 17 00:00:00 2001
Josh Boyer c9d9c5
From: Josh Boyer <jwboyer@fedoraproject.org>
Josh Boyer c9d9c5
Date: Fri, 26 Oct 2012 14:02:09 -0400
Josh Boyer c9d9c5
Subject: [PATCH] hibernate: Disable in a signed modules environment
Josh Boyer c9d9c5
Josh Boyer c9d9c5
There is currently no way to verify the resume image when returning
Josh Boyer c9d9c5
from hibernate.  This might compromise the signed modules trust model,
Josh Boyer c9d9c5
so until we can work with signed hibernate images we disable it in
Josh Boyer c9d9c5
a secure modules environment.
Josh Boyer c9d9c5
Josh Boyer c9d9c5
Signed-off-by: Josh Boyer <jwboyer@fedoraproject.com>
Josh Boyer c9d9c5
---
Josh Boyer c9d9c5
 kernel/power/hibernate.c | 16 +++++++++++++++-
Josh Boyer c9d9c5
 kernel/power/main.c      |  7 ++++++-
Josh Boyer d7ee6f
 kernel/power/user.c      |  1 +
Josh Boyer d7ee6f
 3 files changed, 22 insertions(+), 2 deletions(-)
Josh Boyer c9d9c5
Josh Boyer c9d9c5
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
Josh Boyer c9d9c5
index b26f5f1..e65228b 100644
Josh Boyer c9d9c5
--- a/kernel/power/hibernate.c
Josh Boyer c9d9c5
+++ b/kernel/power/hibernate.c
Josh Boyer c9d9c5
@@ -28,6 +28,8 @@
Josh Boyer c9d9c5
 #include <linux/syscore_ops.h>
Josh Boyer c9d9c5
 #include <linux/ctype.h>
Josh Boyer c9d9c5
 #include <linux/genhd.h>
Josh Boyer c9d9c5
+#include <linux/efi.h>
Josh Boyer c9d9c5
+#include <linux/module.h>
Josh Boyer c9d9c5
 
Josh Boyer c9d9c5
 #include "power.h"
Josh Boyer c9d9c5
 
Josh Boyer c9d9c5
@@ -632,6 +634,10 @@ int hibernate(void)
Josh Boyer c9d9c5
 {
Josh Boyer c9d9c5
 	int error;
Josh Boyer c9d9c5
 
Josh Boyer c9d9c5
+	if (secure_modules()) {
Josh Boyer c9d9c5
+		return -EPERM;
Josh Boyer c9d9c5
+	}
Josh Boyer c9d9c5
+
Josh Boyer c9d9c5
 	lock_system_sleep();
Josh Boyer c9d9c5
 	/* The snapshot device should not be opened while we're running */
Josh Boyer c9d9c5
 	if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
Josh Boyer c9d9c5
@@ -723,7 +729,7 @@ static int software_resume(void)
Josh Boyer c9d9c5
 	/*
Josh Boyer c9d9c5
 	 * If the user said "noresume".. bail out early.
Josh Boyer c9d9c5
 	 */
Josh Boyer c9d9c5
-	if (noresume)
Josh Boyer c9d9c5
+	if (noresume || secure_modules())
Josh Boyer c9d9c5
 		return 0;
Josh Boyer c9d9c5
 
Josh Boyer c9d9c5
 	/*
Josh Boyer c9d9c5
@@ -889,6 +895,11 @@ static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr,
Josh Boyer c9d9c5
 	int i;
Josh Boyer c9d9c5
 	char *start = buf;
Josh Boyer c9d9c5
 
Josh Boyer c9d9c5
+	if (efi_enabled(EFI_SECURE_BOOT)) {
Josh Boyer c9d9c5
+		buf += sprintf(buf, "[%s]\n", "disabled");
Josh Boyer c9d9c5
+		return buf-start;
Josh Boyer c9d9c5
+	}
Josh Boyer c9d9c5
+
Josh Boyer c9d9c5
 	for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) {
Josh Boyer c9d9c5
 		if (!hibernation_modes[i])
Josh Boyer c9d9c5
 			continue;
Josh Boyer c9d9c5
@@ -923,6 +934,9 @@ static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr,
Josh Boyer c9d9c5
 	char *p;
Josh Boyer c9d9c5
 	int mode = HIBERNATION_INVALID;
Josh Boyer c9d9c5
 
Josh Boyer c9d9c5
+	if (secure_modules())
Josh Boyer c9d9c5
+		return -EPERM;
Josh Boyer c9d9c5
+
Josh Boyer c9d9c5
 	p = memchr(buf, '\n', n);
Josh Boyer c9d9c5
 	len = p ? p - buf : n;
Josh Boyer c9d9c5
 
Josh Boyer c9d9c5
diff --git a/kernel/power/main.c b/kernel/power/main.c
Josh Boyer c9d9c5
index 1d1bf63..300f300 100644
Josh Boyer c9d9c5
--- a/kernel/power/main.c
Josh Boyer c9d9c5
+++ b/kernel/power/main.c
Josh Boyer c9d9c5
@@ -15,6 +15,7 @@
Josh Boyer c9d9c5
 #include <linux/workqueue.h>
Josh Boyer c9d9c5
 #include <linux/debugfs.h>
Josh Boyer c9d9c5
 #include <linux/seq_file.h>
Josh Boyer c9d9c5
+#include <linux/efi.h>
Josh Boyer c9d9c5
 
Josh Boyer c9d9c5
 #include "power.h"
Josh Boyer c9d9c5
 
Josh Boyer c9d9c5
@@ -301,7 +302,11 @@ static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
Josh Boyer c9d9c5
 	}
Josh Boyer c9d9c5
 #endif
Josh Boyer c9d9c5
 #ifdef CONFIG_HIBERNATION
Josh Boyer c9d9c5
-	s += sprintf(s, "%s\n", "disk");
Josh Boyer c9d9c5
+	if (!efi_enabled(EFI_SECURE_BOOT)) {
Josh Boyer c9d9c5
+		s += sprintf(s, "%s\n", "disk");
Josh Boyer c9d9c5
+	} else {
Josh Boyer c9d9c5
+		s += sprintf(s, "\n");
Josh Boyer c9d9c5
+	}
Josh Boyer c9d9c5
 #else
Josh Boyer c9d9c5
 	if (s != buf)
Josh Boyer c9d9c5
 		/* convert the last space to a newline */
Josh Boyer c9d9c5
diff --git a/kernel/power/user.c b/kernel/power/user.c
Josh Boyer d7ee6f
index 15cb72f..fa85ed5 100644
Josh Boyer c9d9c5
--- a/kernel/power/user.c
Josh Boyer c9d9c5
+++ b/kernel/power/user.c
Josh Boyer d7ee6f
@@ -25,6 +25,7 @@
Josh Boyer c9d9c5
 #include <linux/cpu.h>
Josh Boyer c9d9c5
 #include <linux/freezer.h>
Josh Boyer d7ee6f
 #include <linux/module.h>
Josh Boyer c9d9c5
+#include <linux/efi.h>
Josh Boyer c9d9c5
 
Josh Boyer c9d9c5
 #include <asm/uaccess.h>
Josh Boyer c9d9c5
 
Josh Boyer c9d9c5
-- 
Josh Boyer c9d9c5
1.8.3.1
Josh Boyer c9d9c5