diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/module.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/kernel/module.c b/kernel/module.c index 8674a390a2e8..8e4528c9909f 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -890,6 +890,19 @@ static struct module_attribute *modinfo_attrs[] = { | |||
890 | 890 | ||
891 | static const char vermagic[] = VERMAGIC_STRING; | 891 | static const char vermagic[] = VERMAGIC_STRING; |
892 | 892 | ||
893 | static int try_to_force_load(struct module *mod, const char *symname) | ||
894 | { | ||
895 | #ifdef CONFIG_MODULE_FORCE_LOAD | ||
896 | if (!(tainted & TAINT_FORCED_MODULE)) | ||
897 | printk("%s: no version for \"%s\" found: kernel tainted.\n", | ||
898 | mod->name, symname); | ||
899 | add_taint_module(mod, TAINT_FORCED_MODULE); | ||
900 | return 0; | ||
901 | #else | ||
902 | return -ENOEXEC; | ||
903 | #endif | ||
904 | } | ||
905 | |||
893 | #ifdef CONFIG_MODVERSIONS | 906 | #ifdef CONFIG_MODVERSIONS |
894 | static int check_version(Elf_Shdr *sechdrs, | 907 | static int check_version(Elf_Shdr *sechdrs, |
895 | unsigned int versindex, | 908 | unsigned int versindex, |
@@ -914,18 +927,18 @@ static int check_version(Elf_Shdr *sechdrs, | |||
914 | 927 | ||
915 | if (versions[i].crc == *crc) | 928 | if (versions[i].crc == *crc) |
916 | return 1; | 929 | return 1; |
917 | printk("%s: disagrees about version of symbol %s\n", | ||
918 | mod->name, symname); | ||
919 | DEBUGP("Found checksum %lX vs module %lX\n", | 930 | DEBUGP("Found checksum %lX vs module %lX\n", |
920 | *crc, versions[i].crc); | 931 | *crc, versions[i].crc); |
921 | return 0; | 932 | goto bad_version; |
922 | } | 933 | } |
923 | /* Not in module's version table. OK, but that taints the kernel. */ | 934 | |
924 | if (!(tainted & TAINT_FORCED_MODULE)) | 935 | if (!try_to_force_load(mod, symname)) |
925 | printk("%s: no version for \"%s\" found: kernel tainted.\n", | 936 | return 1; |
926 | mod->name, symname); | 937 | |
927 | add_taint_module(mod, TAINT_FORCED_MODULE); | 938 | bad_version: |
928 | return 1; | 939 | printk("%s: disagrees about version of symbol %s\n", |
940 | mod->name, symname); | ||
941 | return 0; | ||
929 | } | 942 | } |
930 | 943 | ||
931 | static inline int check_modstruct_version(Elf_Shdr *sechdrs, | 944 | static inline int check_modstruct_version(Elf_Shdr *sechdrs, |
@@ -1853,9 +1866,9 @@ static struct module *load_module(void __user *umod, | |||
1853 | modmagic = get_modinfo(sechdrs, infoindex, "vermagic"); | 1866 | modmagic = get_modinfo(sechdrs, infoindex, "vermagic"); |
1854 | /* This is allowed: modprobe --force will invalidate it. */ | 1867 | /* This is allowed: modprobe --force will invalidate it. */ |
1855 | if (!modmagic) { | 1868 | if (!modmagic) { |
1856 | add_taint_module(mod, TAINT_FORCED_MODULE); | 1869 | err = try_to_force_load(mod, "magic"); |
1857 | printk(KERN_WARNING "%s: no version magic, tainting kernel.\n", | 1870 | if (err) |
1858 | mod->name); | 1871 | goto free_hdr; |
1859 | } else if (!same_magic(modmagic, vermagic)) { | 1872 | } else if (!same_magic(modmagic, vermagic)) { |
1860 | printk(KERN_ERR "%s: version magic '%s' should be '%s'\n", | 1873 | printk(KERN_ERR "%s: version magic '%s' should be '%s'\n", |
1861 | mod->name, modmagic, vermagic); | 1874 | mod->name, modmagic, vermagic); |
@@ -2006,9 +2019,10 @@ static struct module *load_module(void __user *umod, | |||
2006 | (mod->num_gpl_future_syms && !gplfuturecrcindex) || | 2019 | (mod->num_gpl_future_syms && !gplfuturecrcindex) || |
2007 | (mod->num_unused_syms && !unusedcrcindex) || | 2020 | (mod->num_unused_syms && !unusedcrcindex) || |
2008 | (mod->num_unused_gpl_syms && !unusedgplcrcindex)) { | 2021 | (mod->num_unused_gpl_syms && !unusedgplcrcindex)) { |
2009 | printk(KERN_WARNING "%s: No versions for exported symbols." | 2022 | printk(KERN_WARNING "%s: No versions for exported symbols.\n", mod->name); |
2010 | " Tainting kernel.\n", mod->name); | 2023 | err = try_to_force_load(mod, "nocrc"); |
2011 | add_taint_module(mod, TAINT_FORCED_MODULE); | 2024 | if (err) |
2025 | goto cleanup; | ||
2012 | } | 2026 | } |
2013 | #endif | 2027 | #endif |
2014 | markersindex = find_sec(hdr, sechdrs, secstrings, "__markers"); | 2028 | markersindex = find_sec(hdr, sechdrs, secstrings, "__markers"); |