2016-10-27 14:49:53 +00:00
|
|
|
From 85968a9f0b3f05c56d4ac4002748f3412a9baab0 Mon Sep 17 00:00:00 2001
|
2014-08-20 17:22:24 +00:00
|
|
|
From: Matthew Garrett <matthew.garrett@nebula.com>
|
|
|
|
Date: Fri, 9 Aug 2013 03:33:56 -0400
|
2016-10-27 14:49:53 +00:00
|
|
|
Subject: [PATCH 08/20] kexec: Disable at runtime if the kernel enforces module
|
2014-08-20 17:22:24 +00:00
|
|
|
loading restrictions
|
|
|
|
|
|
|
|
kexec permits the loading and execution of arbitrary code in ring 0, which
|
|
|
|
is something that module signing enforcement is meant to prevent. It makes
|
|
|
|
sense to disable kexec in this situation.
|
|
|
|
|
|
|
|
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
|
|
|
|
---
|
|
|
|
kernel/kexec.c | 8 ++++++++
|
|
|
|
1 file changed, 8 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/kernel/kexec.c b/kernel/kexec.c
|
2016-10-27 14:49:53 +00:00
|
|
|
index 980936a90ee6..fce28bf7d5d7 100644
|
2014-08-20 17:22:24 +00:00
|
|
|
--- a/kernel/kexec.c
|
|
|
|
+++ b/kernel/kexec.c
|
2016-10-27 14:49:53 +00:00
|
|
|
@@ -12,6 +12,7 @@
|
2015-09-11 14:10:27 +00:00
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/file.h>
|
|
|
|
#include <linux/kexec.h>
|
2014-08-20 17:22:24 +00:00
|
|
|
+#include <linux/module.h>
|
2015-09-11 14:10:27 +00:00
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/syscalls.h>
|
2016-10-27 14:49:53 +00:00
|
|
|
@@ -194,6 +195,13 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
|
2014-08-20 17:22:24 +00:00
|
|
|
return -EPERM;
|
|
|
|
|
|
|
|
/*
|
|
|
|
+ * kexec can be used to circumvent module loading restrictions, so
|
|
|
|
+ * prevent loading in that case
|
|
|
|
+ */
|
|
|
|
+ if (secure_modules())
|
|
|
|
+ return -EPERM;
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
* Verify we have a legal set of flags
|
|
|
|
* This leaves us room for future extensions.
|
|
|
|
*/
|
2015-09-09 15:10:06 +00:00
|
|
|
--
|
2016-10-27 14:49:53 +00:00
|
|
|
2.9.3
|
2015-09-09 15:10:06 +00:00
|
|
|
|