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