6a9155
From: Matthew Garrett <matthew.garrett@nebula.com>
6a9155
Date: Fri, 9 Aug 2013 17:58:15 -0400
6a9155
Subject: [PATCH] Add secure_modules() call
6a9155
6a9155
Provide a single call to allow kernel code to determine whether the system
6a9155
has been configured to either disable module loading entirely or to load
6a9155
only modules signed with a trusted key.
6a9155
6a9155
Bugzilla: N/A
6a9155
Upstream-status: Fedora mustard.  Replaced by securelevels, but that was nak'd
6a9155
6a9155
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
6a9155
---
76c11d
 include/linux/module.h |  6 ++++++
6a9155
 kernel/module.c        | 10 ++++++++++
76c11d
 2 files changed, 16 insertions(+)
6a9155
6a9155
diff --git a/include/linux/module.h b/include/linux/module.h
088a50
index d67b1932cc59..57474384b66b 100644
6a9155
--- a/include/linux/module.h
6a9155
+++ b/include/linux/module.h
088a50
@@ -551,6 +551,8 @@ static inline bool module_requested_async_probing(struct module *module)
76c11d
 	return module && module->async_probe_requested;
76c11d
 }
6a9155
 
6a9155
+extern bool secure_modules(void);
6a9155
+
6a9155
 #else /* !CONFIG_MODULES... */
6a9155
 
6a9155
 /* Given an address, look for it in the exception tables. */
088a50
@@ -667,6 +669,10 @@ static inline bool module_requested_async_probing(struct module *module)
76c11d
 	return false;
6a9155
 }
76c11d
 
6a9155
+static inline bool secure_modules(void)
6a9155
+{
6a9155
+	return false;
6a9155
+}
6a9155
 #endif /* CONFIG_MODULES */
6a9155
 
6a9155
 #ifdef CONFIG_SYSFS
6a9155
diff --git a/kernel/module.c b/kernel/module.c
228ccc
index 4d2b82e610e2..e9869c497175 100644
6a9155
--- a/kernel/module.c
6a9155
+++ b/kernel/module.c
228ccc
@@ -4083,3 +4083,13 @@ void module_layout(struct module *mod,
6a9155
 }
6a9155
 EXPORT_SYMBOL(module_layout);
6a9155
 #endif
6a9155
+
6a9155
+bool secure_modules(void)
6a9155
+{
6a9155
+#ifdef CONFIG_MODULE_SIG
6a9155
+	return (sig_enforce || modules_disabled);
6a9155
+#else
6a9155
+	return modules_disabled;
6a9155
+#endif
6a9155
+}
6a9155
+EXPORT_SYMBOL(secure_modules);