diff options
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/kernel/module.c b/kernel/module.c index 152b1655bbac..25bc9ac9e226 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -100,7 +100,7 @@ static inline int strong_try_module_get(struct module *mod) | |||
100 | static inline void add_taint_module(struct module *mod, unsigned flag) | 100 | static inline void add_taint_module(struct module *mod, unsigned flag) |
101 | { | 101 | { |
102 | add_taint(flag); | 102 | add_taint(flag); |
103 | mod->taints |= flag; | 103 | mod->taints |= (1U << flag); |
104 | } | 104 | } |
105 | 105 | ||
106 | /* | 106 | /* |
@@ -784,6 +784,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags) | |||
784 | mutex_lock(&module_mutex); | 784 | mutex_lock(&module_mutex); |
785 | /* Store the name of the last unloaded module for diagnostic purposes */ | 785 | /* Store the name of the last unloaded module for diagnostic purposes */ |
786 | strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); | 786 | strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); |
787 | unregister_dynamic_debug_module(mod->name); | ||
787 | free_module(mod); | 788 | free_module(mod); |
788 | 789 | ||
789 | out: | 790 | out: |
@@ -923,7 +924,7 @@ static const char vermagic[] = VERMAGIC_STRING; | |||
923 | static int try_to_force_load(struct module *mod, const char *symname) | 924 | static int try_to_force_load(struct module *mod, const char *symname) |
924 | { | 925 | { |
925 | #ifdef CONFIG_MODULE_FORCE_LOAD | 926 | #ifdef CONFIG_MODULE_FORCE_LOAD |
926 | if (!(tainted & TAINT_FORCED_MODULE)) | 927 | if (!test_taint(TAINT_FORCED_MODULE)) |
927 | printk("%s: no version for \"%s\" found: kernel tainted.\n", | 928 | printk("%s: no version for \"%s\" found: kernel tainted.\n", |
928 | mod->name, symname); | 929 | mod->name, symname); |
929 | add_taint_module(mod, TAINT_FORCED_MODULE); | 930 | add_taint_module(mod, TAINT_FORCED_MODULE); |
@@ -1033,7 +1034,7 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs, | |||
1033 | const unsigned long *crc; | 1034 | const unsigned long *crc; |
1034 | 1035 | ||
1035 | ret = find_symbol(name, &owner, &crc, | 1036 | ret = find_symbol(name, &owner, &crc, |
1036 | !(mod->taints & TAINT_PROPRIETARY_MODULE), true); | 1037 | !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true); |
1037 | if (!IS_ERR_VALUE(ret)) { | 1038 | if (!IS_ERR_VALUE(ret)) { |
1038 | /* use_module can fail due to OOM, | 1039 | /* use_module can fail due to OOM, |
1039 | or module initialization or unloading */ | 1040 | or module initialization or unloading */ |
@@ -1173,7 +1174,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs, | |||
1173 | while (i-- > 0) | 1174 | while (i-- > 0) |
1174 | sysfs_remove_bin_file(notes_attrs->dir, | 1175 | sysfs_remove_bin_file(notes_attrs->dir, |
1175 | ¬es_attrs->attrs[i]); | 1176 | ¬es_attrs->attrs[i]); |
1176 | kobject_del(notes_attrs->dir); | 1177 | kobject_put(notes_attrs->dir); |
1177 | } | 1178 | } |
1178 | kfree(notes_attrs); | 1179 | kfree(notes_attrs); |
1179 | } | 1180 | } |
@@ -1634,7 +1635,7 @@ static void set_license(struct module *mod, const char *license) | |||
1634 | license = "unspecified"; | 1635 | license = "unspecified"; |
1635 | 1636 | ||
1636 | if (!license_is_gpl_compatible(license)) { | 1637 | if (!license_is_gpl_compatible(license)) { |
1637 | if (!(tainted & TAINT_PROPRIETARY_MODULE)) | 1638 | if (!test_taint(TAINT_PROPRIETARY_MODULE)) |
1638 | printk(KERN_WARNING "%s: module license '%s' taints " | 1639 | printk(KERN_WARNING "%s: module license '%s' taints " |
1639 | "kernel.\n", mod->name, license); | 1640 | "kernel.\n", mod->name, license); |
1640 | add_taint_module(mod, TAINT_PROPRIETARY_MODULE); | 1641 | add_taint_module(mod, TAINT_PROPRIETARY_MODULE); |
@@ -1783,6 +1784,33 @@ static inline void add_kallsyms(struct module *mod, | |||
1783 | } | 1784 | } |
1784 | #endif /* CONFIG_KALLSYMS */ | 1785 | #endif /* CONFIG_KALLSYMS */ |
1785 | 1786 | ||
1787 | #ifdef CONFIG_DYNAMIC_PRINTK_DEBUG | ||
1788 | static void dynamic_printk_setup(Elf_Shdr *sechdrs, unsigned int verboseindex) | ||
1789 | { | ||
1790 | struct mod_debug *debug_info; | ||
1791 | unsigned long pos, end; | ||
1792 | unsigned int num_verbose; | ||
1793 | |||
1794 | pos = sechdrs[verboseindex].sh_addr; | ||
1795 | num_verbose = sechdrs[verboseindex].sh_size / | ||
1796 | sizeof(struct mod_debug); | ||
1797 | end = pos + (num_verbose * sizeof(struct mod_debug)); | ||
1798 | |||
1799 | for (; pos < end; pos += sizeof(struct mod_debug)) { | ||
1800 | debug_info = (struct mod_debug *)pos; | ||
1801 | register_dynamic_debug_module(debug_info->modname, | ||
1802 | debug_info->type, debug_info->logical_modname, | ||
1803 | debug_info->flag_names, debug_info->hash, | ||
1804 | debug_info->hash2); | ||
1805 | } | ||
1806 | } | ||
1807 | #else | ||
1808 | static inline void dynamic_printk_setup(Elf_Shdr *sechdrs, | ||
1809 | unsigned int verboseindex) | ||
1810 | { | ||
1811 | } | ||
1812 | #endif /* CONFIG_DYNAMIC_PRINTK_DEBUG */ | ||
1813 | |||
1786 | static void *module_alloc_update_bounds(unsigned long size) | 1814 | static void *module_alloc_update_bounds(unsigned long size) |
1787 | { | 1815 | { |
1788 | void *ret = module_alloc(size); | 1816 | void *ret = module_alloc(size); |
@@ -1832,6 +1860,7 @@ static noinline struct module *load_module(void __user *umod, | |||
1832 | #endif | 1860 | #endif |
1833 | unsigned int markersindex; | 1861 | unsigned int markersindex; |
1834 | unsigned int markersstringsindex; | 1862 | unsigned int markersstringsindex; |
1863 | unsigned int verboseindex; | ||
1835 | struct module *mod; | 1864 | struct module *mod; |
1836 | long err = 0; | 1865 | long err = 0; |
1837 | void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ | 1866 | void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ |
@@ -2126,6 +2155,7 @@ static noinline struct module *load_module(void __user *umod, | |||
2126 | markersindex = find_sec(hdr, sechdrs, secstrings, "__markers"); | 2155 | markersindex = find_sec(hdr, sechdrs, secstrings, "__markers"); |
2127 | markersstringsindex = find_sec(hdr, sechdrs, secstrings, | 2156 | markersstringsindex = find_sec(hdr, sechdrs, secstrings, |
2128 | "__markers_strings"); | 2157 | "__markers_strings"); |
2158 | verboseindex = find_sec(hdr, sechdrs, secstrings, "__verbose"); | ||
2129 | 2159 | ||
2130 | /* Now do relocations. */ | 2160 | /* Now do relocations. */ |
2131 | for (i = 1; i < hdr->e_shnum; i++) { | 2161 | for (i = 1; i < hdr->e_shnum; i++) { |
@@ -2176,6 +2206,7 @@ static noinline struct module *load_module(void __user *umod, | |||
2176 | marker_update_probe_range(mod->markers, | 2206 | marker_update_probe_range(mod->markers, |
2177 | mod->markers + mod->num_markers); | 2207 | mod->markers + mod->num_markers); |
2178 | #endif | 2208 | #endif |
2209 | dynamic_printk_setup(sechdrs, verboseindex); | ||
2179 | err = module_finalize(hdr, sechdrs, mod); | 2210 | err = module_finalize(hdr, sechdrs, mod); |
2180 | if (err < 0) | 2211 | if (err < 0) |
2181 | goto cleanup; | 2212 | goto cleanup; |
@@ -2561,11 +2592,11 @@ static char *module_flags(struct module *mod, char *buf) | |||
2561 | mod->state == MODULE_STATE_GOING || | 2592 | mod->state == MODULE_STATE_GOING || |
2562 | mod->state == MODULE_STATE_COMING) { | 2593 | mod->state == MODULE_STATE_COMING) { |
2563 | buf[bx++] = '('; | 2594 | buf[bx++] = '('; |
2564 | if (mod->taints & TAINT_PROPRIETARY_MODULE) | 2595 | if (mod->taints & (1 << TAINT_PROPRIETARY_MODULE)) |
2565 | buf[bx++] = 'P'; | 2596 | buf[bx++] = 'P'; |
2566 | if (mod->taints & TAINT_FORCED_MODULE) | 2597 | if (mod->taints & (1 << TAINT_FORCED_MODULE)) |
2567 | buf[bx++] = 'F'; | 2598 | buf[bx++] = 'F'; |
2568 | if (mod->taints & TAINT_CRAP) | 2599 | if (mod->taints & (1 << TAINT_CRAP)) |
2569 | buf[bx++] = 'C'; | 2600 | buf[bx++] = 'C'; |
2570 | /* | 2601 | /* |
2571 | * TAINT_FORCED_RMMOD: could be added. | 2602 | * TAINT_FORCED_RMMOD: could be added. |