Commit e24c9231 authored by Rusty Russell's avatar Rusty Russell Committed by Kai Germaschewski

kbuild: Ignore kernel version part of vermagic if CONFIG_MODVERSIONS

Skip over the first part of __vermagic in modversioning is on: otherwise
you'll have to force it when changing from 2.6.0 to 2.6.1.
parent 2fe90be7
...@@ -767,6 +767,14 @@ static int check_version(Elf_Shdr *sechdrs, ...@@ -767,6 +767,14 @@ static int check_version(Elf_Shdr *sechdrs,
} }
return 1; return 1;
} }
/* First part is kernel version, which we ignore. */
static inline int same_magic(const char *amagic, const char *bmagic)
{
amagic += strcspn(amagic, " ");
bmagic += strcspn(bmagic, " ");
return strcmp(amagic, bmagic) == 0;
}
#else #else
static inline int check_version(Elf_Shdr *sechdrs, static inline int check_version(Elf_Shdr *sechdrs,
unsigned int versindex, unsigned int versindex,
...@@ -777,6 +785,11 @@ static inline int check_version(Elf_Shdr *sechdrs, ...@@ -777,6 +785,11 @@ static inline int check_version(Elf_Shdr *sechdrs,
{ {
return 1; return 1;
} }
static inline int same_magic(const char *amagic, const char *bmagic)
{
return strcmp(amagic, bmagic) == 0;
}
#endif /* CONFIG_MODVERSIONS */ #endif /* CONFIG_MODVERSIONS */
/* Resolve a symbol for this module. I.e. if we find one, record usage. /* Resolve a symbol for this module. I.e. if we find one, record usage.
...@@ -1177,7 +1190,7 @@ static struct module *load_module(void *umod, ...@@ -1177,7 +1190,7 @@ static struct module *load_module(void *umod,
tainted |= TAINT_FORCED_MODULE; tainted |= TAINT_FORCED_MODULE;
printk(KERN_WARNING "%s: no version magic, tainting kernel.\n", printk(KERN_WARNING "%s: no version magic, tainting kernel.\n",
mod->name); mod->name);
} else if (strcmp((char *)sechdrs[vmagindex].sh_addr, vermagic) != 0) { } else if (!same_magic((char *)sechdrs[vmagindex].sh_addr, vermagic)) {
printk(KERN_ERR "%s: version magic '%s' should be '%s'\n", printk(KERN_ERR "%s: version magic '%s' should be '%s'\n",
mod->name, (char*)sechdrs[vmagindex].sh_addr, vermagic); mod->name, (char*)sechdrs[vmagindex].sh_addr, vermagic);
err = -ENOEXEC; err = -ENOEXEC;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment