diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2008-05-09 16:25:28 +1000 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-05-09 07:45:18 -0700 |
commit | 91e37a793b5a9436a2d12b2f0a8f52db3a133e1d (patch) | |
tree | 6ddf17ad786fa2a42ef79aa4f7873c79c1e17a89 /kernel | |
parent | a5dd69707424a35d2d2cc094e870f595ad61e916 (diff) | |
download | kernel_samsung_aries-91e37a793b5a9436a2d12b2f0a8f52db3a133e1d.zip kernel_samsung_aries-91e37a793b5a9436a2d12b2f0a8f52db3a133e1d.tar.gz kernel_samsung_aries-91e37a793b5a9436a2d12b2f0a8f52db3a133e1d.tar.bz2 |
module: don't ignore vermagic string if module doesn't have modversions
Linus found a logic bug: we ignore the version number in a module's
vermagic string if we have CONFIG_MODVERSIONS set, but modversions
also lets through a module with no __versions section for modprobe
--force (with tainting, but still).
We should only ignore the start of the vermagic string if the module
actually *has* crcs to check. Rather than (say) having an
entertaining hissy fit and creating a config option to work around the
buggy code.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/module.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/kernel/module.c b/kernel/module.c index 2584c0e..f5e9491 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -957,11 +957,14 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs, return check_version(sechdrs, versindex, "struct_module", mod, crc); } -/* First part is kernel version, which we ignore. */ -static inline int same_magic(const char *amagic, const char *bmagic) +/* First part is kernel version, which we ignore if module has crcs. */ +static inline int same_magic(const char *amagic, const char *bmagic, + bool has_crcs) { - amagic += strcspn(amagic, " "); - bmagic += strcspn(bmagic, " "); + if (has_crcs) { + amagic += strcspn(amagic, " "); + bmagic += strcspn(bmagic, " "); + } return strcmp(amagic, bmagic) == 0; } #else @@ -981,7 +984,8 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs, return 1; } -static inline int same_magic(const char *amagic, const char *bmagic) +static inline int same_magic(const char *amagic, const char *bmagic, + bool has_crcs) { return strcmp(amagic, bmagic) == 0; } @@ -1874,7 +1878,7 @@ static struct module *load_module(void __user *umod, err = try_to_force_load(mod, "magic"); if (err) goto free_hdr; - } else if (!same_magic(modmagic, vermagic)) { + } else if (!same_magic(modmagic, vermagic, versindex)) { printk(KERN_ERR "%s: version magic '%s' should be '%s'\n", mod->name, modmagic, vermagic); err = -ENOEXEC; |