0f09adf
From: Matthew Garrett <matthew.garrett@nebula.com>
0f09adf
Date: Fri, 9 Aug 2013 17:58:15 -0400
0f09adf
Subject: [PATCH] Add secure_modules() call
0f09adf
0f09adf
Provide a single call to allow kernel code to determine whether the system
0f09adf
has been configured to either disable module loading entirely or to load
0f09adf
only modules signed with a trusted key.
0f09adf
0f09adf
Bugzilla: N/A
0f09adf
Upstream-status: Fedora mustard.  Replaced by securelevels, but that was nak'd
0f09adf
0f09adf
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
0f09adf
---
0f09adf
 include/linux/module.h |  7 +++++++
0f09adf
 kernel/module.c        | 10 ++++++++++
0f09adf
 2 files changed, 17 insertions(+)
0f09adf
0f09adf
diff --git a/include/linux/module.h b/include/linux/module.h
0f09adf
index 71f282a4e307..341a73ecea2e 100644
0f09adf
--- a/include/linux/module.h
0f09adf
+++ b/include/linux/module.h
0f09adf
@@ -516,6 +516,8 @@ int unregister_module_notifier(struct notifier_block *nb);
0f09adf
 
0f09adf
 extern void print_modules(void);
0f09adf
 
0f09adf
+extern bool secure_modules(void);
0f09adf
+
0f09adf
 #else /* !CONFIG_MODULES... */
0f09adf
 
0f09adf
 /* Given an address, look for it in the exception tables. */
0f09adf
@@ -626,6 +628,11 @@ static inline int unregister_module_notifier(struct notifier_block *nb)
0f09adf
 static inline void print_modules(void)
0f09adf
 {
0f09adf
 }
0f09adf
+
0f09adf
+static inline bool secure_modules(void)
0f09adf
+{
0f09adf
+	return false;
0f09adf
+}
0f09adf
 #endif /* CONFIG_MODULES */
0f09adf
 
0f09adf
 #ifdef CONFIG_SYSFS
0f09adf
diff --git a/kernel/module.c b/kernel/module.c
0f09adf
index 03214bd288e9..1f7b4664300e 100644
0f09adf
--- a/kernel/module.c
0f09adf
+++ b/kernel/module.c
0f09adf
@@ -3842,3 +3842,13 @@ void module_layout(struct module *mod,
0f09adf
 }
0f09adf
 EXPORT_SYMBOL(module_layout);
0f09adf
 #endif
0f09adf
+
0f09adf
+bool secure_modules(void)
0f09adf
+{
0f09adf
+#ifdef CONFIG_MODULE_SIG
0f09adf
+	return (sig_enforce || modules_disabled);
0f09adf
+#else
0f09adf
+	return modules_disabled;
0f09adf
+#endif
0f09adf
+}
0f09adf
+EXPORT_SYMBOL(secure_modules);
0f09adf
-- 
0f09adf
1.9.3
0f09adf