From: Dan Aloni <da-x@monatomic.org>
To: Linux Kernel List <linux-kernel@vger.kernel.org>
Subject: [PATCH] allow kernel module exclusion on load
Date: Sun, 13 May 2007 16:25:17 +0300 [thread overview]
Message-ID: <20070513132517.GA14038@localdomain> (raw)
Kernel developers might find it useful for quickly getting out from some
rough debugging scenarios.
Signed-off-by: Dan Aloni <da-x@monatomic.org>
diff --git a/init/Kconfig b/init/Kconfig
index 4e009fd..796715e 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -682,6 +682,17 @@ config KMOD
runs modprobe with the appropriate arguments, thereby
loading the module if it is available. If unsure, say Y.
+config MODULE_EXCLUSION
+ bool "Refuse loading of modules with certain names"
+ depends on MODULES && DEBUG_KERNEL
+ help
+ During kernel module development and debugging you might come
+ into a situation where one of your kernel modules crashes the
+ kernel on boot. This option lets you specify in the kernel
+ command line (via exclude-modules=) a comma-separated list
+ of kernel modules that the kernel will refuse to load based
+ on their names.
+
config STOP_MACHINE
bool
default y
diff --git a/kernel/module.c b/kernel/module.c
index 9bd93de..14457dd 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1551,6 +1551,27 @@ static inline void add_kallsyms(struct module *mod,
}
#endif /* CONFIG_KALLSYMS */
+#ifdef CONFIG_MODULE_EXCLUSION
+
+static char exclusion_names[0x100];
+static int __init module_exclusion_setup(char *str)
+{
+ snprintf(exclusion_names, sizeof(exclusion_names), ",%s,", str);
+ return 1;
+}
+__setup("exclude-modules=", module_exclusion_setup);
+
+static int is_module_excluded(const char *name)
+{
+ char lookup_str[MODULE_NAME_LEN+3];
+ snprintf(lookup_str, sizeof(lookup_str), ",%s,", name);
+ return strstr(exclusion_names, lookup_str) != NULL;
+}
+
+#else
+static inline int is_module_excluded(const char *name) {return 0;}
+#endif
+
/* Allocate and load the module: note that size of section 0 is always
zero, and we rely on this for optional sections. */
static struct module *load_module(void __user *umod,
@@ -1714,6 +1735,11 @@ static struct module *load_module(void __user *umod,
goto free_hdr;
}
+ if (is_module_excluded(mod->name)) {
+ err = -EACCES;
+ goto free_mod;
+ }
+
if (find_module(mod->name)) {
err = -EEXIST;
goto free_mod;
--
Dan Aloni
XIV LTD, http://www.xivstorage.com
da-x (at) monatomic.org, dan (at) xiv.co.il
next reply other threads:[~2007-05-13 13:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-13 13:25 Dan Aloni [this message]
2007-05-13 16:23 ` [PATCH] allow kernel module exclusion on load Stephen Hemminger
2007-05-13 17:05 ` Nikita V. Youshchenko
2007-05-13 17:15 ` Dan Aloni
2007-05-13 18:04 ` Michael Tokarev
2007-05-13 18:22 ` Dan Aloni
2007-05-13 18:32 ` Michael Tokarev
2007-05-13 18:20 ` Christoph Hellwig
2007-05-13 18:39 ` Michael Tokarev
2007-05-15 8:23 ` Pavel Machek
2007-05-16 16:51 ` Dan Aloni
2007-05-16 19:33 ` Pavel Machek
2007-05-16 21:09 ` Dan Aloni
2007-05-16 22:00 ` Randy Dunlap
2007-05-15 13:07 ` Andi Kleen
2007-05-14 20:23 ` Valdis.Kletnieks
2007-05-15 8:48 ` Dan Aloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070513132517.GA14038@localdomain \
--to=da-x@monatomic.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox