aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno E. O. Meneguele <brdeoliv@redhat.com>2017-10-24 13:37:00 -0400
committerMimi Zohar <zohar@linux.vnet.ibm.com>2017-11-08 15:16:36 -0500
commitfda784e50aace694ec2e4e16e2de07b91a938563 (patch)
treec3df3df519da44cda091f23764425cae97715d26
parentebe7c0a7be92bbd34c6ff5b55810546a0ee05bee (diff)
module: export module signature enforcement status
A static variable sig_enforce is used as status var to indicate the real value of CONFIG_MODULE_SIG_FORCE, once this one is set the var will hold true, but if the CONFIG is not set the status var will hold whatever value is present in the module.sig_enforce kernel cmdline param: true when =1 and false when =0 or not present. Considering this cmdline param take place over the CONFIG value when it's not set, other places in the kernel could misbehave since they would have only the CONFIG_MODULE_SIG_FORCE value to rely on. Exporting this status var allows the kernel to rely in the effective value of module signature enforcement, being it from CONFIG value or cmdline param. Signed-off-by: Bruno E. O. Meneguele <brdeoliv@redhat.com> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
-rw-r--r--include/linux/module.h7
-rw-r--r--kernel/module.c10
2 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/module.h b/include/linux/module.h
index fe5aa3736707..c69b49abe877 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -639,6 +639,8 @@ static inline bool is_livepatch_module(struct module *mod)
639} 639}
640#endif /* CONFIG_LIVEPATCH */ 640#endif /* CONFIG_LIVEPATCH */
641 641
642bool is_module_sig_enforced(void);
643
642#else /* !CONFIG_MODULES... */ 644#else /* !CONFIG_MODULES... */
643 645
644static inline struct module *__module_address(unsigned long addr) 646static inline struct module *__module_address(unsigned long addr)
@@ -753,6 +755,11 @@ static inline bool module_requested_async_probing(struct module *module)
753 return false; 755 return false;
754} 756}
755 757
758static inline bool is_module_sig_enforced(void)
759{
760 return false;
761}
762
756#endif /* CONFIG_MODULES */ 763#endif /* CONFIG_MODULES */
757 764
758#ifdef CONFIG_SYSFS 765#ifdef CONFIG_SYSFS
diff --git a/kernel/module.c b/kernel/module.c
index de66ec825992..d1c194b057a2 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -278,6 +278,16 @@ static bool sig_enforce = IS_ENABLED(CONFIG_MODULE_SIG_FORCE);
278module_param(sig_enforce, bool_enable_only, 0644); 278module_param(sig_enforce, bool_enable_only, 0644);
279#endif /* !CONFIG_MODULE_SIG_FORCE */ 279#endif /* !CONFIG_MODULE_SIG_FORCE */
280 280
281/*
282 * Export sig_enforce kernel cmdline parameter to allow other subsystems rely
283 * on that instead of directly to CONFIG_MODULE_SIG_FORCE config.
284 */
285bool is_module_sig_enforced(void)
286{
287 return sig_enforce;
288}
289EXPORT_SYMBOL(is_module_sig_enforced);
290
281/* Block module loading/unloading? */ 291/* Block module loading/unloading? */
282int modules_disabled = 0; 292int modules_disabled = 0;
283core_param(nomodule, modules_disabled, bint, 0); 293core_param(nomodule, modules_disabled, bint, 0);