summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>2003-01-14 22:39:42 -0600
committerKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>2003-01-14 22:39:42 -0600
commitbb9fc49ff383d14d025eb8bbc049921bef110a75 (patch)
treefe278b0be6dc242825fb47c3d10a027db285e56d /kernel
parente29d5f5cef31509adb4b33b73f0ed82b8a58e13e (diff)
parent1d411b80ee1849027d56f86fcf057f29eb4dbe0f (diff)
Merge tp1.ruhr-uni-bochum.de:/scratch/kai/kernel/v2.5/linux-2.5
into tp1.ruhr-uni-bochum.de:/scratch/kai/kernel/v2.5/linux-2.5.make
Diffstat (limited to 'kernel')
-rw-r--r--kernel/module.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 4a31ffeb323d..acae11eea73f 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -963,6 +963,9 @@ static void set_license(struct module *mod, Elf_Shdr *sechdrs, int licenseidx)
}
}
+/* From init/vermagic.o */
+extern char vermagic[];
+
/* 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 *umod,
@@ -973,7 +976,7 @@ static struct module *load_module(void *umod,
Elf_Shdr *sechdrs;
char *secstrings, *args;
unsigned int i, symindex, exportindex, strindex, setupindex, exindex,
- modindex, obsparmindex, licenseindex, gplindex;
+ modindex, obsparmindex, licenseindex, gplindex, vmagindex;
long arglen;
struct module *mod;
long err = 0;
@@ -1012,7 +1015,7 @@ static struct module *load_module(void *umod,
exportindex = setupindex = obsparmindex = gplindex = licenseindex = 0;
/* And these should exist, but gcc whinges if we don't init them */
- symindex = strindex = exindex = modindex = 0;
+ symindex = strindex = exindex = modindex = vmagindex = 0;
/* Find where important sections are */
for (i = 1; i < hdr->e_shnum; i++) {
@@ -1062,6 +1065,11 @@ static struct module *load_module(void *umod,
/* EXPORT_SYMBOL_GPL() */
DEBUGP("GPL symbols found in section %u\n", i);
gplindex = i;
+ } else if (strcmp(secstrings+sechdrs[i].sh_name,
+ "__vermagic") == 0) {
+ /* Version magic. */
+ DEBUGP("Version magic found in section %u\n", i);
+ vmagindex = i;
}
#ifdef CONFIG_KALLSYMS
/* symbol and string tables for decoding later. */
@@ -1082,6 +1090,18 @@ static struct module *load_module(void *umod,
}
mod = (void *)sechdrs[modindex].sh_addr;
+ /* This is allowed: modprobe --force will strip it. */
+ if (!vmagindex) {
+ tainted |= TAINT_FORCED_MODULE;
+ printk(KERN_WARNING "%s: no version magic, tainting kernel.\n",
+ mod->name);
+ } else if (strcmp((char *)sechdrs[vmagindex].sh_addr, vermagic) != 0) {
+ printk(KERN_ERR "%s: version magic '%s' should be '%s'\n",
+ mod->name, (char*)sechdrs[vmagindex].sh_addr, vermagic);
+ err = -ENOEXEC;
+ goto free_hdr;
+ }
+
/* Now copy in args */
arglen = strlen_user(uargs);
if (!arglen) {