0f09adf
From: Matthew Garrett <matthew.garrett@nebula.com>
0f09adf
Date: Fri, 9 Aug 2013 03:33:56 -0400
0f09adf
Subject: [PATCH] kexec: Disable at runtime if the kernel enforces module
0f09adf
 loading restrictions
0f09adf
0f09adf
kexec permits the loading and execution of arbitrary code in ring 0, which
0f09adf
is something that module signing enforcement is meant to prevent. It makes
0f09adf
sense to disable kexec in this situation.
0f09adf
0f09adf
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
0f09adf
---
0f09adf
 kernel/kexec.c | 8 ++++++++
0f09adf
 1 file changed, 8 insertions(+)
0f09adf
0f09adf
diff --git a/kernel/kexec.c b/kernel/kexec.c
0f09adf
index 2bee072268d9..891477dbfee0 100644
0f09adf
--- a/kernel/kexec.c
0f09adf
+++ b/kernel/kexec.c
0f09adf
@@ -36,6 +36,7 @@
0f09adf
 #include <linux/syscore_ops.h>
0f09adf
 #include <linux/compiler.h>
0f09adf
 #include <linux/hugetlb.h>
0f09adf
+#include <linux/module.h>
0f09adf
 
0f09adf
 #include <asm/page.h>
0f09adf
 #include <asm/uaccess.h>
0f09adf
@@ -1251,6 +1252,13 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
0f09adf
 		return -EPERM;
0f09adf
 
0f09adf
 	/*
0f09adf
+	 * kexec can be used to circumvent module loading restrictions, so
0f09adf
+	 * prevent loading in that case
0f09adf
+	 */
0f09adf
+	if (secure_modules())
0f09adf
+		return -EPERM;
0f09adf
+
0f09adf
+	/*
0f09adf
 	 * Verify we have a legal set of flags
0f09adf
 	 * This leaves us room for future extensions.
0f09adf
 	 */
0f09adf
-- 
0f09adf
1.9.3
0f09adf