[RFC PATCH 7/9] module: expose the list of blacklisted modules

Simon THOBY git at nightmared.fr
Wed May 21 14:01:11 UTC 2025


Other kernel components (e.g. the Loadpol LSM) may need to access the
modules blacklist.

Signed-off-by: Simon THOBY <git at nightmared.fr>
---
 include/linux/module.h | 3 +++
 kernel/module/main.c   | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/include/linux/module.h b/include/linux/module.h
index b6b8d6f7f599..2ef50d81dc8d 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -781,6 +781,9 @@ void set_module_sig_enforced(void);
 
 void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data);
 
+/* return a comma-separated list of blacklisted kernel modules */
+const char *get_blacklisted_modules(void);
+
 #else /* !CONFIG_MODULES... */
 
 static inline struct module *__module_address(unsigned long addr)
diff --git a/kernel/module/main.c b/kernel/module/main.c
index 12a1a5f4d823..8f0afbc57df7 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -2765,6 +2765,11 @@ static bool blacklisted(const char *module_name)
 }
 core_param(module_blacklist, module_blacklist, charp, 0400);
 
+const char *get_blacklisted_modules(void)
+{
+	return module_blacklist;
+}
+
 static struct module *layout_and_allocate(struct load_info *info, int flags)
 {
 	struct module *mod;
-- 
2.49.0




More information about the Linux-security-module-archive mailing list