Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Add additional duplicate-module-name check in case ...



details:   https://anonhg.NetBSD.org/src/rev/0d4c77093159
branches:  trunk
changeset: 828365:0d4c77093159
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sun Dec 10 03:08:32 2017 +0000

description:
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.

XXX pullup to netbsd-8

diffstat:

 sys/kern/kern_module.c |  21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diffs (42 lines):

diff -r a69c5e48dc5c -r 0d4c77093159 sys/kern/kern_module.c
--- a/sys/kern/kern_module.c    Sun Dec 10 02:32:03 2017 +0000
+++ b/sys/kern/kern_module.c    Sun Dec 10 03:08:32 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.126 2017/12/10 03:08:32 pgoyette 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.126 2017/12/10 03:08:32 pgoyette 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) {



Home | Main Index | Thread Index | Old Index