History

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.

Bruno E. O. Meneguele committed 9 years ago

Commit fda784e1 parent ebe7c0a2 files · +17 −0Browse files

Unified · Split

2 files
  1. include/linux/module.h +7 −0
  2. kernel/module.c +10 −0
include/linux/module.h+7−0
@@ -639,6 +639,8 @@ static inline bool is_livepatch_module(struct module *mod) · 638 unmodified lines
639639 }
640640 #endif /* CONFIG_LIVEPATCH */
641641
642+bool is_module_sig_enforced(void);
643+
642644 #else /* !CONFIG_MODULES... */
643645
644646 static inline struct module *__module_address(unsigned long addr)
@@ -753,6 +755,11 @@ static inline bool module_requested_async_probing(struct module *module) · 108 unmodified lines
753755 return false;
754756 }
755757
758+static inline bool is_module_sig_enforced(void)
759+{
760+ return false;
761+}
762+
756763 #endif /* CONFIG_MODULES */
757764
758765 #ifdef CONFIG_SYSFS
kernel/module.c+10−0
@@ -278,6 +278,16 @@ static bool sig_enforce = IS_ENABLED(CONFIG_MODULE_SIG_FORCE); · 277 unmodified lines
278278 module_param(sig_enforce, bool_enable_only, 0644);
279279 #endif /* !CONFIG_MODULE_SIG_FORCE */
280280
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+ */
285+bool is_module_sig_enforced(void)
286+{
287+ return sig_enforce;
288+}
289+EXPORT_SYMBOL(is_module_sig_enforced);
290+
281291 /* Block module loading/unloading? */
282292 int modules_disabled = 0;
283293 core_param(nomodule, modules_disabled, bint, 0);