Module Name: src Committed By: pgoyette Date: Wed Mar 19 03:46:15 UTC 2025
Modified Files: src/sys/kern: kern_module.c Log Message: More detailed debug messages. Especially for module_load where we now print the load request info before we try anything, rather than only if we takea particulaar exit path. (Several other exit paths resulted in no messages at all; they are now covered.) To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.163 src/sys/kern/kern_module.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_module.c diff -u src/sys/kern/kern_module.c:1.162 src/sys/kern/kern_module.c:1.163 --- src/sys/kern/kern_module.c:1.162 Mon May 13 00:32:09 2024 +++ src/sys/kern/kern_module.c Wed Mar 19 03:46:15 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_module.c,v 1.162 2024/05/13 00:32:09 msaitoh Exp $ */ +/* $NetBSD: kern_module.c,v 1.163 2025/03/19 03:46:15 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.162 2024/05/13 00:32:09 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.163 2025/03/19 03:46:15 pgoyette Exp $"); #define _MODULE_INTERNAL @@ -706,8 +706,12 @@ module_autoload(const char *filename, mo kernconfig_lock(); + module_print("Autoload for `%s' requested by pid %d (%s)", + filename, p->p_pid, p->p_comm); + /* Nothing if the user has disabled it. */ if (!module_autoload_on) { + module_print("Autoload disabled for `%s' ", filename); kernconfig_unlock(); return EPERM; } @@ -715,6 +719,7 @@ module_autoload(const char *filename, mo /* Disallow path separators and magic symlinks. */ if (strchr(filename, '/') != NULL || strchr(filename, '@') != NULL || strchr(filename, '.') != NULL) { + module_print("Autoload illegal path for `%s' ", filename); kernconfig_unlock(); return EPERM; } @@ -723,12 +728,14 @@ module_autoload(const char *filename, mo error = kauth_authorize_system(kauth_cred_get(), KAUTH_SYSTEM_MODULE, 0, (void *)(uintptr_t)MODCTL_LOAD, (void *)(uintptr_t)1, NULL); - if (error == 0) - error = module_do_load(filename, false, 0, NULL, NULL, modclass, - true); + if (error != 0) { + module_print("Autoload not authorized for `%s' ", filename); + kernconfig_unlock(); + return error; + } + error = module_do_load(filename, false, 0, NULL, NULL, modclass, true); - module_print("Autoload for `%s' requested by pid %d (%s), status %d", - filename, p->p_pid, p->p_comm, error); + module_print("Autoload for `%s' status %d", filename, error); kernconfig_unlock(); return error; } @@ -1468,7 +1475,7 @@ module_do_unload(const char *name, bool KASSERT(kernconfig_is_held()); KASSERT(name != NULL); - module_print("unload requested for '%s' (%s)", name, + module_print("unload requested for '%s' (requires_force %s)", name, load_requires_force ? "TRUE" : "FALSE"); mod = module_lookup(name); if (mod == NULL) {