Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/kern Pull up following revision(s) (requested by pgoy...
details: https://anonhg.NetBSD.org/src/rev/17ce3027accb
branches: netbsd-8
changeset: 851238:17ce3027accb
user: snj <snj%NetBSD.org@localhost>
date: Thu Dec 21 21:37:03 2017 +0000
description:
Pull up following revision(s) (requested by pgoyette in ticket #449):
sys/kern/kern_module.c: 1.126-1.130
Add additional duplicate-module-name check in case we have two modules
with the same internal name but no conflicting symbol definitions.
When we load a module from the file system, the filename may have no
relationship to the internal module's name. Furthermore, comparing
the module's filename is insufficient if the file is loaded from an
absolute path.
--
Use KASSERT to ensure that the newly-added module's name can be found.
--
Change a KASSERTMSG into a regular module_error - not nice for the
kernel
to panic when I try to modload the 'ntfs' module.
--
When looking for a duplicate module name, also check the pending list.
--
Remove the check for duplicate-module-name-on-pending-list since it really
doesn't help. The check really cannot fail, and it only looks at the list
belonging to the current level of recursion.
Instead, verify that the module's modcmd(MODULE_CMD_INIT, ...) does not
introduce a duplicate module name as a result of recursively calling
module_do_load().
diffstat:
sys/kern/kern_module.c | 35 +++++++++++++++++++++++++++++++++--
1 files changed, 33 insertions(+), 2 deletions(-)
diffs (70 lines):
diff -r f3190037aa88 -r 17ce3027accb sys/kern/kern_module.c
--- a/sys/kern/kern_module.c Thu Dec 21 21:33:31 2017 +0000
+++ b/sys/kern/kern_module.c Thu Dec 21 21:37:03 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_module.c,v 1.125 2017/06/01 02:45:13 chs Exp $ */
+/* $NetBSD: kern_module.c,v 1.125.2.1 2017/12/21 21:37:03 snj Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.125 2017/06/01 02:45:13 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.125.2.1 2017/12/21 21:37:03 snj Exp $");
#define _MODULE_INTERNAL
@@ -1039,6 +1039,23 @@
}
/*
+ * If we loaded a module from the filesystem, check the actual
+ * module name (from the modinfo_t) to ensure another module
+ * with the same name doesn't already exist. (There's no
+ * guarantee the filename will match the module name, and the
+ * dup-symbols check may not be sufficient.)
+ */
+ if (mod->mod_source == MODULE_SOURCE_FILESYS) {
+ mod2 = module_lookup(mod->mod_info->mi_name);
+ if ( mod2 && mod2 != mod) {
+ module_error("module with name `%s' already loaded",
+ mod2->mod_info->mi_name);
+ error = EEXIST;
+ goto fail;
+ }
+ }
+
+ /*
* Block circular dependencies.
*/
TAILQ_FOREACH(mod2, pending, mod_chain) {
@@ -1133,6 +1150,18 @@
}
/*
+ * If a recursive load already added a module with the same
+ * name, abort.
+ */
+ mod2 = module_lookup(mi->mi_name);
+ if (mod2 && mod2 != mod) {
+ module_error("recursive load causes duplicate module `%s'",
+ mi->mi_name);
+ error = EEXIST;
+ goto fail1;
+ }
+
+ /*
* Good, the module loaded successfully. Put it onto the
* list and add references to its requisite modules.
*/
@@ -1154,6 +1183,8 @@
module_print("module `%s' loaded successfully", mi->mi_name);
return 0;
+ fail1:
+ (*mi->mi_modcmd)(MODULE_CMD_FINI, NULL);
fail:
kobj_unload(mod->mod_kobj);
fail2:
Home |
Main Index |
Thread Index |
Old Index