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