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