Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163505777
D57002.id177904.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D57002.id177904.diff
View Options
diff --git a/sbin/kldload/kldload.c b/sbin/kldload/kldload.c
--- a/sbin/kldload/kldload.c
+++ b/sbin/kldload/kldload.c
@@ -95,8 +95,9 @@
if (sb.st_dev != dev || sb.st_ino != ino) {
if (!quiet)
- warnx("%s will be loaded from %s, not the "
- "current directory", kldname, element);
+ warnx(
+"%s will be loaded from %s, not the current directory",
+ kldname, element);
break;
} else if (sb.st_dev == dev && sb.st_ino == ino)
break;
@@ -171,18 +172,17 @@
if (!quiet) {
switch (errno) {
case EEXIST:
- warnx("can't load %s: module "
- "already loaded or "
- "in kernel", argv[0]);
+ warnx(
+"can't load %s: module already loaded or in kernel", argv[0]);
break;
case ENOEXEC:
- warnx("an error occurred while "
- "loading module %s. "
- "Please check dmesg(8) for "
- "more details.", argv[0]);
+ warnx(
+"an error occurred while loading module %s. Please check dmesg(8) for more details.",
+ argv[0]);
break;
default:
- warn("can't load %s", argv[0]);
+ warn("can't load %s",
+ argv[0]);
break;
}
}
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -55,6 +55,9 @@
#include <sys/sysproto.h>
#include <sys/vnode.h>
+#define EXTERR_CATEGORY EXTERR_CAT_LINKER
+#include <sys/exterrvar.h>
+
#ifdef DDB
#include <ddb/ddb.h>
#endif
@@ -455,13 +458,15 @@
/* Refuse to load modules if securelevel raised */
if (prison0.pr_securelevel > 0)
- return (EPERM);
+ return (EXTERROR(EPERM,
+"Attempted to load module when current security level %jd does not permit it",
+ prison0.pr_securelevel));
sx_assert(&kld_sx, SA_XLOCKED);
lf = linker_find_file_by_name(filename);
if (lf) {
- KLD_DPF(FILE, ("linker_load_file: file %s is already loaded,"
- " incrementing refs\n", filename));
+ KLD_DPF(FILE,
+("linker_load_file: file %s is already loaded, incrementing refs\n", filename));
*result = lf;
lf->refs++;
return (0);
@@ -508,7 +513,8 @@
*/
if (modules && TAILQ_EMPTY(&lf->modules)) {
linker_file_unload(lf, LINKER_UNLOAD_FORCE);
- return (ENOEXEC);
+ return (EXTERROR(ENOEXEC,
+ "Failed to load modules from linker file"));
}
linker_file_enable_sysctls(lf);
@@ -543,9 +549,12 @@
* dialog boxes.
*/
if (error != EEXIST)
- error = ENOEXEC;
+ error = EXTERROR(ENOEXEC,
+"A KLD module is unrecognizable, has incompatible version, or is unloadable");
} else
- error = ENOENT; /* Nothing found */
+ error = EXTERROR(ENOENT,
+"File from which KLD module load was attempted could not be found");
+ /* Nothing found */
return (error);
}
@@ -2259,16 +2268,19 @@
/*
* We have to load KLD
*/
- KASSERT(verinfo == NULL, ("linker_load_module: verinfo"
- " is not NULL"));
+ KASSERT(verinfo == NULL,
+ ("linker_load_module: verinfo is not NULL"));
if (!linker_root_mounted())
- return (ENXIO);
+ return (EXTERROR(ENXIO,
+"Thread or filesystem root inaccessible while attempting to load KLD module"));
pathname = linker_search_kld(kldname);
} else {
if (modlist_lookup2(modname, verinfo) != NULL)
- return (EEXIST);
+ return (EXTERROR(EEXIST,
+"Attempted to load an already-loaded module with a valid version number"));
if (!linker_root_mounted())
- return (ENXIO);
+ return (EXTERROR(ENXIO,
+"Thread or filesystem root inaccessible while attempting to load KLD module"));
if (kldname != NULL)
pathname = strdup(kldname, M_LINKER);
else
@@ -2279,7 +2291,8 @@
strlen(modname), verinfo);
}
if (pathname == NULL)
- return (ENOENT);
+ return (EXTERROR(ENOENT,
+ "Attempted to load a KLD module that could not be found"));
/*
* Can't load more than one file with the same basename XXX:
@@ -2288,16 +2301,29 @@
* provide different versions of the same modules.
*/
filename = linker_basename(pathname);
- if (linker_find_file_by_name(filename))
- error = EEXIST;
- else do {
+ lfdep = linker_find_file_by_name(filename);
+ if (lfdep) {
+ if (modname && verinfo &&
+ modlist_lookup2(modname, verinfo) == NULL) {
+ /*
+ * Desired module is in the linker, but the correct
+ * version does not exist.
+ */
+ error = EXTERROR(ENOEXEC,
+"Module is loaded already, but with an incompatible version");
+ } else {
+ return (EXTERROR(EEXIST,
+"Attempted to load an already-loaded module with a valid version number"));
+ }
+ } else do {
error = linker_load_file(pathname, &lfdep);
if (error)
break;
if (modname && verinfo &&
modlist_lookup2(modname, verinfo) == NULL) {
linker_file_unload(lfdep, LINKER_UNLOAD_FORCE);
- error = ENOENT;
+ error = EXTERROR(ENOEXEC,
+"Module is loaded already, but with an incompatible version");
break;
}
if (parent)
@@ -2343,10 +2369,12 @@
ver = ((const struct mod_version *)mp->md_data)->mv_version;
mod = modlist_lookup(modname, ver);
if (mod != NULL) {
- printf("interface %s.%d already present in the KLD"
- " '%s'!\n", modname, ver,
- mod->container->filename);
- return (EEXIST);
+ printf(
+"interface %s.%d already present in the KLD '%s'!\n",
+ modname, ver, mod->container->filename);
+ return (EXTERROR(EEXIST,
+"Attempted to load an already-loaded interface into the KLD",
+ modname, ver));
}
}
@@ -2376,8 +2404,9 @@
}
error = linker_load_module(NULL, modname, lf, verinfo, NULL);
if (error) {
- printf("KLD %s: depends on %s - not available or"
- " version mismatch\n", lf->filename, modname);
+ printf(
+"KLD %s: depends on %s - not available or version mismatch\n",
+ lf->filename, modname);
break;
}
}
diff --git a/sys/sys/exterr_cat.h b/sys/sys/exterr_cat.h
--- a/sys/sys/exterr_cat.h
+++ b/sys/sys/exterr_cat.h
@@ -39,6 +39,7 @@
#define EXTERR_CAT_FUSE_DEVICE 14
#define EXTERR_CAT_FORK 15
#define EXTERR_CAT_PROCEXIT 16
+#define EXTERR_CAT_LINKER 17
#endif
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 24, 10:12 PM (14 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35454381
Default Alt Text
D57002.id177904.diff (5 KB)
Attached To
Mode
D57002: Bug 295139 - kldload prints wrong error message to terminal upon attempt to load incorrect module version
Attached
Detach File
Event Timeline
Log In to Comment