diff options
Diffstat (limited to 'kernel/module.c')
| -rw-r--r-- | kernel/module.c | 394 |
1 files changed, 249 insertions, 145 deletions
diff --git a/kernel/module.c b/kernel/module.c index 9db11911e04b..1f4cc00e0c20 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
| @@ -20,11 +20,13 @@ | |||
| 20 | #include <linux/moduleloader.h> | 20 | #include <linux/moduleloader.h> |
| 21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
| 22 | #include <linux/kallsyms.h> | 22 | #include <linux/kallsyms.h> |
| 23 | #include <linux/fs.h> | ||
| 23 | #include <linux/sysfs.h> | 24 | #include <linux/sysfs.h> |
| 24 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
| 25 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
| 26 | #include <linux/vmalloc.h> | 27 | #include <linux/vmalloc.h> |
| 27 | #include <linux/elf.h> | 28 | #include <linux/elf.h> |
| 29 | #include <linux/proc_fs.h> | ||
| 28 | #include <linux/seq_file.h> | 30 | #include <linux/seq_file.h> |
| 29 | #include <linux/syscalls.h> | 31 | #include <linux/syscalls.h> |
| 30 | #include <linux/fcntl.h> | 32 | #include <linux/fcntl.h> |
| @@ -42,10 +44,13 @@ | |||
| 42 | #include <linux/string.h> | 44 | #include <linux/string.h> |
| 43 | #include <linux/mutex.h> | 45 | #include <linux/mutex.h> |
| 44 | #include <linux/unwind.h> | 46 | #include <linux/unwind.h> |
| 47 | #include <linux/rculist.h> | ||
| 45 | #include <asm/uaccess.h> | 48 | #include <asm/uaccess.h> |
| 46 | #include <asm/cacheflush.h> | 49 | #include <asm/cacheflush.h> |
| 47 | #include <linux/license.h> | 50 | #include <linux/license.h> |
| 48 | #include <asm/sections.h> | 51 | #include <asm/sections.h> |
| 52 | #include <linux/tracepoint.h> | ||
| 53 | #include <linux/ftrace.h> | ||
| 49 | 54 | ||
| 50 | #if 0 | 55 | #if 0 |
| 51 | #define DEBUGP printk | 56 | #define DEBUGP printk |
| @@ -61,7 +66,7 @@ | |||
| 61 | #define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1)) | 66 | #define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1)) |
| 62 | 67 | ||
| 63 | /* List of modules, protected by module_mutex or preempt_disable | 68 | /* List of modules, protected by module_mutex or preempt_disable |
| 64 | * (add/delete uses stop_machine). */ | 69 | * (delete uses stop_machine/add uses RCU list operations). */ |
| 65 | static DEFINE_MUTEX(module_mutex); | 70 | static DEFINE_MUTEX(module_mutex); |
| 66 | static LIST_HEAD(modules); | 71 | static LIST_HEAD(modules); |
| 67 | 72 | ||
| @@ -100,7 +105,7 @@ static inline int strong_try_module_get(struct module *mod) | |||
| 100 | static inline void add_taint_module(struct module *mod, unsigned flag) | 105 | static inline void add_taint_module(struct module *mod, unsigned flag) |
| 101 | { | 106 | { |
| 102 | add_taint(flag); | 107 | add_taint(flag); |
| 103 | mod->taints |= flag; | 108 | mod->taints |= (1U << flag); |
| 104 | } | 109 | } |
| 105 | 110 | ||
| 106 | /* | 111 | /* |
| @@ -130,6 +135,29 @@ static unsigned int find_sec(Elf_Ehdr *hdr, | |||
| 130 | return 0; | 135 | return 0; |
| 131 | } | 136 | } |
| 132 | 137 | ||
| 138 | /* Find a module section, or NULL. */ | ||
| 139 | static void *section_addr(Elf_Ehdr *hdr, Elf_Shdr *shdrs, | ||
| 140 | const char *secstrings, const char *name) | ||
| 141 | { | ||
| 142 | /* Section 0 has sh_addr 0. */ | ||
| 143 | return (void *)shdrs[find_sec(hdr, shdrs, secstrings, name)].sh_addr; | ||
| 144 | } | ||
| 145 | |||
| 146 | /* Find a module section, or NULL. Fill in number of "objects" in section. */ | ||
| 147 | static void *section_objs(Elf_Ehdr *hdr, | ||
| 148 | Elf_Shdr *sechdrs, | ||
| 149 | const char *secstrings, | ||
| 150 | const char *name, | ||
| 151 | size_t object_size, | ||
| 152 | unsigned int *num) | ||
| 153 | { | ||
| 154 | unsigned int sec = find_sec(hdr, sechdrs, secstrings, name); | ||
| 155 | |||
| 156 | /* Section 0 has sh_addr 0 and sh_size 0. */ | ||
| 157 | *num = sechdrs[sec].sh_size / object_size; | ||
| 158 | return (void *)sechdrs[sec].sh_addr; | ||
| 159 | } | ||
| 160 | |||
| 133 | /* Provided by the linker */ | 161 | /* Provided by the linker */ |
| 134 | extern const struct kernel_symbol __start___ksymtab[]; | 162 | extern const struct kernel_symbol __start___ksymtab[]; |
| 135 | extern const struct kernel_symbol __stop___ksymtab[]; | 163 | extern const struct kernel_symbol __stop___ksymtab[]; |
| @@ -216,7 +244,7 @@ static bool each_symbol(bool (*fn)(const struct symsearch *arr, | |||
| 216 | if (each_symbol_in_section(arr, ARRAY_SIZE(arr), NULL, fn, data)) | 244 | if (each_symbol_in_section(arr, ARRAY_SIZE(arr), NULL, fn, data)) |
| 217 | return true; | 245 | return true; |
| 218 | 246 | ||
| 219 | list_for_each_entry(mod, &modules, list) { | 247 | list_for_each_entry_rcu(mod, &modules, list) { |
| 220 | struct symsearch arr[] = { | 248 | struct symsearch arr[] = { |
| 221 | { mod->syms, mod->syms + mod->num_syms, mod->crcs, | 249 | { mod->syms, mod->syms + mod->num_syms, mod->crcs, |
| 222 | NOT_GPL_ONLY, false }, | 250 | NOT_GPL_ONLY, false }, |
| @@ -784,6 +812,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags) | |||
| 784 | mutex_lock(&module_mutex); | 812 | mutex_lock(&module_mutex); |
| 785 | /* Store the name of the last unloaded module for diagnostic purposes */ | 813 | /* Store the name of the last unloaded module for diagnostic purposes */ |
| 786 | strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); | 814 | strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); |
| 815 | unregister_dynamic_debug_module(mod->name); | ||
| 787 | free_module(mod); | 816 | free_module(mod); |
| 788 | 817 | ||
| 789 | out: | 818 | out: |
| @@ -923,7 +952,7 @@ static const char vermagic[] = VERMAGIC_STRING; | |||
| 923 | static int try_to_force_load(struct module *mod, const char *symname) | 952 | static int try_to_force_load(struct module *mod, const char *symname) |
| 924 | { | 953 | { |
| 925 | #ifdef CONFIG_MODULE_FORCE_LOAD | 954 | #ifdef CONFIG_MODULE_FORCE_LOAD |
| 926 | if (!(tainted & TAINT_FORCED_MODULE)) | 955 | if (!test_taint(TAINT_FORCED_MODULE)) |
| 927 | printk("%s: no version for \"%s\" found: kernel tainted.\n", | 956 | printk("%s: no version for \"%s\" found: kernel tainted.\n", |
| 928 | mod->name, symname); | 957 | mod->name, symname); |
| 929 | add_taint_module(mod, TAINT_FORCED_MODULE); | 958 | add_taint_module(mod, TAINT_FORCED_MODULE); |
| @@ -1033,7 +1062,7 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs, | |||
| 1033 | const unsigned long *crc; | 1062 | const unsigned long *crc; |
| 1034 | 1063 | ||
| 1035 | ret = find_symbol(name, &owner, &crc, | 1064 | ret = find_symbol(name, &owner, &crc, |
| 1036 | !(mod->taints & TAINT_PROPRIETARY_MODULE), true); | 1065 | !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true); |
| 1037 | if (!IS_ERR_VALUE(ret)) { | 1066 | if (!IS_ERR_VALUE(ret)) { |
| 1038 | /* use_module can fail due to OOM, | 1067 | /* use_module can fail due to OOM, |
| 1039 | or module initialization or unloading */ | 1068 | or module initialization or unloading */ |
| @@ -1173,7 +1202,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs, | |||
| 1173 | while (i-- > 0) | 1202 | while (i-- > 0) |
| 1174 | sysfs_remove_bin_file(notes_attrs->dir, | 1203 | sysfs_remove_bin_file(notes_attrs->dir, |
| 1175 | ¬es_attrs->attrs[i]); | 1204 | ¬es_attrs->attrs[i]); |
| 1176 | kobject_del(notes_attrs->dir); | 1205 | kobject_put(notes_attrs->dir); |
| 1177 | } | 1206 | } |
| 1178 | kfree(notes_attrs); | 1207 | kfree(notes_attrs); |
| 1179 | } | 1208 | } |
| @@ -1391,17 +1420,6 @@ static void mod_kobject_remove(struct module *mod) | |||
| 1391 | } | 1420 | } |
| 1392 | 1421 | ||
| 1393 | /* | 1422 | /* |
| 1394 | * link the module with the whole machine is stopped with interrupts off | ||
| 1395 | * - this defends against kallsyms not taking locks | ||
| 1396 | */ | ||
| 1397 | static int __link_module(void *_mod) | ||
| 1398 | { | ||
| 1399 | struct module *mod = _mod; | ||
| 1400 | list_add(&mod->list, &modules); | ||
| 1401 | return 0; | ||
| 1402 | } | ||
| 1403 | |||
| 1404 | /* | ||
| 1405 | * unlink the module with the whole machine is stopped with interrupts off | 1423 | * unlink the module with the whole machine is stopped with interrupts off |
| 1406 | * - this defends against kallsyms not taking locks | 1424 | * - this defends against kallsyms not taking locks |
| 1407 | */ | 1425 | */ |
| @@ -1429,6 +1447,9 @@ static void free_module(struct module *mod) | |||
| 1429 | /* Module unload stuff */ | 1447 | /* Module unload stuff */ |
| 1430 | module_unload_free(mod); | 1448 | module_unload_free(mod); |
| 1431 | 1449 | ||
| 1450 | /* release any pointers to mcount in this module */ | ||
| 1451 | ftrace_release(mod->module_core, mod->core_size); | ||
| 1452 | |||
| 1432 | /* This may be NULL, but that's OK */ | 1453 | /* This may be NULL, but that's OK */ |
| 1433 | module_free(mod, mod->module_init); | 1454 | module_free(mod, mod->module_init); |
| 1434 | kfree(mod->args); | 1455 | kfree(mod->args); |
| @@ -1634,7 +1655,7 @@ static void set_license(struct module *mod, const char *license) | |||
| 1634 | license = "unspecified"; | 1655 | license = "unspecified"; |
| 1635 | 1656 | ||
| 1636 | if (!license_is_gpl_compatible(license)) { | 1657 | if (!license_is_gpl_compatible(license)) { |
| 1637 | if (!(tainted & TAINT_PROPRIETARY_MODULE)) | 1658 | if (!test_taint(TAINT_PROPRIETARY_MODULE)) |
| 1638 | printk(KERN_WARNING "%s: module license '%s' taints " | 1659 | printk(KERN_WARNING "%s: module license '%s' taints " |
| 1639 | "kernel.\n", mod->name, license); | 1660 | "kernel.\n", mod->name, license); |
| 1640 | add_taint_module(mod, TAINT_PROPRIETARY_MODULE); | 1661 | add_taint_module(mod, TAINT_PROPRIETARY_MODULE); |
| @@ -1783,6 +1804,21 @@ static inline void add_kallsyms(struct module *mod, | |||
| 1783 | } | 1804 | } |
| 1784 | #endif /* CONFIG_KALLSYMS */ | 1805 | #endif /* CONFIG_KALLSYMS */ |
| 1785 | 1806 | ||
| 1807 | static void dynamic_printk_setup(struct mod_debug *debug, unsigned int num) | ||
| 1808 | { | ||
| 1809 | #ifdef CONFIG_DYNAMIC_PRINTK_DEBUG | ||
| 1810 | unsigned int i; | ||
| 1811 | |||
| 1812 | for (i = 0; i < num; i++) { | ||
| 1813 | register_dynamic_debug_module(debug[i].modname, | ||
| 1814 | debug[i].type, | ||
| 1815 | debug[i].logical_modname, | ||
| 1816 | debug[i].flag_names, | ||
| 1817 | debug[i].hash, debug[i].hash2); | ||
| 1818 | } | ||
| 1819 | #endif /* CONFIG_DYNAMIC_PRINTK_DEBUG */ | ||
| 1820 | } | ||
| 1821 | |||
| 1786 | static void *module_alloc_update_bounds(unsigned long size) | 1822 | static void *module_alloc_update_bounds(unsigned long size) |
| 1787 | { | 1823 | { |
| 1788 | void *ret = module_alloc(size); | 1824 | void *ret = module_alloc(size); |
| @@ -1806,35 +1842,18 @@ static noinline struct module *load_module(void __user *umod, | |||
| 1806 | Elf_Ehdr *hdr; | 1842 | Elf_Ehdr *hdr; |
| 1807 | Elf_Shdr *sechdrs; | 1843 | Elf_Shdr *sechdrs; |
| 1808 | char *secstrings, *args, *modmagic, *strtab = NULL; | 1844 | char *secstrings, *args, *modmagic, *strtab = NULL; |
| 1845 | char *staging; | ||
| 1809 | unsigned int i; | 1846 | unsigned int i; |
| 1810 | unsigned int symindex = 0; | 1847 | unsigned int symindex = 0; |
| 1811 | unsigned int strindex = 0; | 1848 | unsigned int strindex = 0; |
| 1812 | unsigned int setupindex; | 1849 | unsigned int modindex, versindex, infoindex, pcpuindex; |
| 1813 | unsigned int exindex; | ||
| 1814 | unsigned int exportindex; | ||
| 1815 | unsigned int modindex; | ||
| 1816 | unsigned int obsparmindex; | ||
| 1817 | unsigned int infoindex; | ||
| 1818 | unsigned int gplindex; | ||
| 1819 | unsigned int crcindex; | ||
| 1820 | unsigned int gplcrcindex; | ||
| 1821 | unsigned int versindex; | ||
| 1822 | unsigned int pcpuindex; | ||
| 1823 | unsigned int gplfutureindex; | ||
| 1824 | unsigned int gplfuturecrcindex; | ||
| 1825 | unsigned int unwindex = 0; | 1850 | unsigned int unwindex = 0; |
| 1826 | #ifdef CONFIG_UNUSED_SYMBOLS | 1851 | unsigned int num_kp, num_mcount; |
| 1827 | unsigned int unusedindex; | 1852 | struct kernel_param *kp; |
| 1828 | unsigned int unusedcrcindex; | ||
| 1829 | unsigned int unusedgplindex; | ||
| 1830 | unsigned int unusedgplcrcindex; | ||
| 1831 | #endif | ||
| 1832 | unsigned int markersindex; | ||
| 1833 | unsigned int markersstringsindex; | ||
| 1834 | struct module *mod; | 1853 | struct module *mod; |
| 1835 | long err = 0; | 1854 | long err = 0; |
| 1836 | void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ | 1855 | void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ |
| 1837 | struct exception_table_entry *extable; | 1856 | unsigned long *mseg; |
| 1838 | mm_segment_t old_fs; | 1857 | mm_segment_t old_fs; |
| 1839 | 1858 | ||
| 1840 | DEBUGP("load_module: umod=%p, len=%lu, uargs=%p\n", | 1859 | DEBUGP("load_module: umod=%p, len=%lu, uargs=%p\n", |
| @@ -1898,6 +1917,7 @@ static noinline struct module *load_module(void __user *umod, | |||
| 1898 | err = -ENOEXEC; | 1917 | err = -ENOEXEC; |
| 1899 | goto free_hdr; | 1918 | goto free_hdr; |
| 1900 | } | 1919 | } |
| 1920 | /* This is temporary: point mod into copy of data. */ | ||
| 1901 | mod = (void *)sechdrs[modindex].sh_addr; | 1921 | mod = (void *)sechdrs[modindex].sh_addr; |
| 1902 | 1922 | ||
| 1903 | if (symindex == 0) { | 1923 | if (symindex == 0) { |
| @@ -1907,22 +1927,6 @@ static noinline struct module *load_module(void __user *umod, | |||
| 1907 | goto free_hdr; | 1927 | goto free_hdr; |
| 1908 | } | 1928 | } |
| 1909 | 1929 | ||
| 1910 | /* Optional sections */ | ||
| 1911 | exportindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab"); | ||
| 1912 | gplindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl"); | ||
| 1913 | gplfutureindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl_future"); | ||
| 1914 | crcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab"); | ||
| 1915 | gplcrcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab_gpl"); | ||
| 1916 | gplfuturecrcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab_gpl_future"); | ||
| 1917 | #ifdef CONFIG_UNUSED_SYMBOLS | ||
| 1918 | unusedindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_unused"); | ||
| 1919 | unusedgplindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_unused_gpl"); | ||
| 1920 | unusedcrcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab_unused"); | ||
| 1921 | unusedgplcrcindex = find_sec(hdr, sechdrs, secstrings, "__kcrctab_unused_gpl"); | ||
| 1922 | #endif | ||
| 1923 | setupindex = find_sec(hdr, sechdrs, secstrings, "__param"); | ||
| 1924 | exindex = find_sec(hdr, sechdrs, secstrings, "__ex_table"); | ||
| 1925 | obsparmindex = find_sec(hdr, sechdrs, secstrings, "__obsparm"); | ||
| 1926 | versindex = find_sec(hdr, sechdrs, secstrings, "__versions"); | 1930 | versindex = find_sec(hdr, sechdrs, secstrings, "__versions"); |
| 1927 | infoindex = find_sec(hdr, sechdrs, secstrings, ".modinfo"); | 1931 | infoindex = find_sec(hdr, sechdrs, secstrings, ".modinfo"); |
| 1928 | pcpuindex = find_pcpusec(hdr, sechdrs, secstrings); | 1932 | pcpuindex = find_pcpusec(hdr, sechdrs, secstrings); |
| @@ -1960,6 +1964,14 @@ static noinline struct module *load_module(void __user *umod, | |||
| 1960 | goto free_hdr; | 1964 | goto free_hdr; |
| 1961 | } | 1965 | } |
| 1962 | 1966 | ||
| 1967 | staging = get_modinfo(sechdrs, infoindex, "staging"); | ||
| 1968 | if (staging) { | ||
| 1969 | add_taint_module(mod, TAINT_CRAP); | ||
| 1970 | printk(KERN_WARNING "%s: module is from the staging directory," | ||
| 1971 | " the quality is unknown, you have been warned.\n", | ||
| 1972 | mod->name); | ||
| 1973 | } | ||
| 1974 | |||
| 1963 | /* Now copy in args */ | 1975 | /* Now copy in args */ |
| 1964 | args = strndup_user(uargs, ~0UL >> 1); | 1976 | args = strndup_user(uargs, ~0UL >> 1); |
| 1965 | if (IS_ERR(args)) { | 1977 | if (IS_ERR(args)) { |
| @@ -2070,42 +2082,57 @@ static noinline struct module *load_module(void __user *umod, | |||
| 2070 | if (err < 0) | 2082 | if (err < 0) |
| 2071 | goto cleanup; | 2083 | goto cleanup; |
| 2072 | 2084 | ||
| 2073 | /* Set up EXPORTed & EXPORT_GPLed symbols (section 0 is 0 length) */ | 2085 | /* Now we've got everything in the final locations, we can |
| 2074 | mod->num_syms = sechdrs[exportindex].sh_size / sizeof(*mod->syms); | 2086 | * find optional sections. */ |
| 2075 | mod->syms = (void *)sechdrs[exportindex].sh_addr; | 2087 | kp = section_objs(hdr, sechdrs, secstrings, "__param", sizeof(*kp), |
| 2076 | if (crcindex) | 2088 | &num_kp); |
| 2077 | mod->crcs = (void *)sechdrs[crcindex].sh_addr; | 2089 | mod->syms = section_objs(hdr, sechdrs, secstrings, "__ksymtab", |
| 2078 | mod->num_gpl_syms = sechdrs[gplindex].sh_size / sizeof(*mod->gpl_syms); | 2090 | sizeof(*mod->syms), &mod->num_syms); |
| 2079 | mod->gpl_syms = (void *)sechdrs[gplindex].sh_addr; | 2091 | mod->crcs = section_addr(hdr, sechdrs, secstrings, "__kcrctab"); |
| 2080 | if (gplcrcindex) | 2092 | mod->gpl_syms = section_objs(hdr, sechdrs, secstrings, "__ksymtab_gpl", |
| 2081 | mod->gpl_crcs = (void *)sechdrs[gplcrcindex].sh_addr; | 2093 | sizeof(*mod->gpl_syms), |
| 2082 | mod->num_gpl_future_syms = sechdrs[gplfutureindex].sh_size / | 2094 | &mod->num_gpl_syms); |
| 2083 | sizeof(*mod->gpl_future_syms); | 2095 | mod->gpl_crcs = section_addr(hdr, sechdrs, secstrings, "__kcrctab_gpl"); |
| 2084 | mod->gpl_future_syms = (void *)sechdrs[gplfutureindex].sh_addr; | 2096 | mod->gpl_future_syms = section_objs(hdr, sechdrs, secstrings, |
| 2085 | if (gplfuturecrcindex) | 2097 | "__ksymtab_gpl_future", |
| 2086 | mod->gpl_future_crcs = (void *)sechdrs[gplfuturecrcindex].sh_addr; | 2098 | sizeof(*mod->gpl_future_syms), |
| 2099 | &mod->num_gpl_future_syms); | ||
| 2100 | mod->gpl_future_crcs = section_addr(hdr, sechdrs, secstrings, | ||
| 2101 | "__kcrctab_gpl_future"); | ||
| 2087 | 2102 | ||
| 2088 | #ifdef CONFIG_UNUSED_SYMBOLS | 2103 | #ifdef CONFIG_UNUSED_SYMBOLS |
| 2089 | mod->num_unused_syms = sechdrs[unusedindex].sh_size / | 2104 | mod->unused_syms = section_objs(hdr, sechdrs, secstrings, |
| 2090 | sizeof(*mod->unused_syms); | 2105 | "__ksymtab_unused", |
| 2091 | mod->num_unused_gpl_syms = sechdrs[unusedgplindex].sh_size / | 2106 | sizeof(*mod->unused_syms), |
| 2092 | sizeof(*mod->unused_gpl_syms); | 2107 | &mod->num_unused_syms); |
| 2093 | mod->unused_syms = (void *)sechdrs[unusedindex].sh_addr; | 2108 | mod->unused_crcs = section_addr(hdr, sechdrs, secstrings, |
| 2094 | if (unusedcrcindex) | 2109 | "__kcrctab_unused"); |
| 2095 | mod->unused_crcs = (void *)sechdrs[unusedcrcindex].sh_addr; | 2110 | mod->unused_gpl_syms = section_objs(hdr, sechdrs, secstrings, |
| 2096 | mod->unused_gpl_syms = (void *)sechdrs[unusedgplindex].sh_addr; | 2111 | "__ksymtab_unused_gpl", |
| 2097 | if (unusedgplcrcindex) | 2112 | sizeof(*mod->unused_gpl_syms), |
| 2098 | mod->unused_gpl_crcs | 2113 | &mod->num_unused_gpl_syms); |
| 2099 | = (void *)sechdrs[unusedgplcrcindex].sh_addr; | 2114 | mod->unused_gpl_crcs = section_addr(hdr, sechdrs, secstrings, |
| 2115 | "__kcrctab_unused_gpl"); | ||
| 2116 | #endif | ||
| 2117 | |||
| 2118 | #ifdef CONFIG_MARKERS | ||
| 2119 | mod->markers = section_objs(hdr, sechdrs, secstrings, "__markers", | ||
| 2120 | sizeof(*mod->markers), &mod->num_markers); | ||
| 2121 | #endif | ||
| 2122 | #ifdef CONFIG_TRACEPOINTS | ||
| 2123 | mod->tracepoints = section_objs(hdr, sechdrs, secstrings, | ||
| 2124 | "__tracepoints", | ||
| 2125 | sizeof(*mod->tracepoints), | ||
| 2126 | &mod->num_tracepoints); | ||
| 2100 | #endif | 2127 | #endif |
| 2101 | 2128 | ||
| 2102 | #ifdef CONFIG_MODVERSIONS | 2129 | #ifdef CONFIG_MODVERSIONS |
| 2103 | if ((mod->num_syms && !crcindex) | 2130 | if ((mod->num_syms && !mod->crcs) |
| 2104 | || (mod->num_gpl_syms && !gplcrcindex) | 2131 | || (mod->num_gpl_syms && !mod->gpl_crcs) |
| 2105 | || (mod->num_gpl_future_syms && !gplfuturecrcindex) | 2132 | || (mod->num_gpl_future_syms && !mod->gpl_future_crcs) |
| 2106 | #ifdef CONFIG_UNUSED_SYMBOLS | 2133 | #ifdef CONFIG_UNUSED_SYMBOLS |
| 2107 | || (mod->num_unused_syms && !unusedcrcindex) | 2134 | || (mod->num_unused_syms && !mod->unused_crcs) |
| 2108 | || (mod->num_unused_gpl_syms && !unusedgplcrcindex) | 2135 | || (mod->num_unused_gpl_syms && !mod->unused_gpl_crcs) |
| 2109 | #endif | 2136 | #endif |
| 2110 | ) { | 2137 | ) { |
| 2111 | printk(KERN_WARNING "%s: No versions for exported symbols.\n", mod->name); | 2138 | printk(KERN_WARNING "%s: No versions for exported symbols.\n", mod->name); |
| @@ -2114,9 +2141,6 @@ static noinline struct module *load_module(void __user *umod, | |||
| 2114 | goto cleanup; | 2141 | goto cleanup; |
| 2115 | } | 2142 | } |
| 2116 | #endif | 2143 | #endif |
| 2117 | markersindex = find_sec(hdr, sechdrs, secstrings, "__markers"); | ||
| 2118 | markersstringsindex = find_sec(hdr, sechdrs, secstrings, | ||
| 2119 | "__markers_strings"); | ||
| 2120 | 2144 | ||
| 2121 | /* Now do relocations. */ | 2145 | /* Now do relocations. */ |
| 2122 | for (i = 1; i < hdr->e_shnum; i++) { | 2146 | for (i = 1; i < hdr->e_shnum; i++) { |
| @@ -2139,22 +2163,16 @@ static noinline struct module *load_module(void __user *umod, | |||
| 2139 | if (err < 0) | 2163 | if (err < 0) |
| 2140 | goto cleanup; | 2164 | goto cleanup; |
| 2141 | } | 2165 | } |
| 2142 | #ifdef CONFIG_MARKERS | ||
| 2143 | mod->markers = (void *)sechdrs[markersindex].sh_addr; | ||
| 2144 | mod->num_markers = | ||
| 2145 | sechdrs[markersindex].sh_size / sizeof(*mod->markers); | ||
| 2146 | #endif | ||
| 2147 | 2166 | ||
| 2148 | /* Find duplicate symbols */ | 2167 | /* Find duplicate symbols */ |
| 2149 | err = verify_export_symbols(mod); | 2168 | err = verify_export_symbols(mod); |
| 2150 | |||
| 2151 | if (err < 0) | 2169 | if (err < 0) |
| 2152 | goto cleanup; | 2170 | goto cleanup; |
| 2153 | 2171 | ||
| 2154 | /* Set up and sort exception table */ | 2172 | /* Set up and sort exception table */ |
| 2155 | mod->num_exentries = sechdrs[exindex].sh_size / sizeof(*mod->extable); | 2173 | mod->extable = section_objs(hdr, sechdrs, secstrings, "__ex_table", |
| 2156 | mod->extable = extable = (void *)sechdrs[exindex].sh_addr; | 2174 | sizeof(*mod->extable), &mod->num_exentries); |
| 2157 | sort_extable(extable, extable + mod->num_exentries); | 2175 | sort_extable(mod->extable, mod->extable + mod->num_exentries); |
| 2158 | 2176 | ||
| 2159 | /* Finally, copy percpu area over. */ | 2177 | /* Finally, copy percpu area over. */ |
| 2160 | percpu_modcopy(mod->percpu, (void *)sechdrs[pcpuindex].sh_addr, | 2178 | percpu_modcopy(mod->percpu, (void *)sechdrs[pcpuindex].sh_addr, |
| @@ -2162,11 +2180,29 @@ static noinline struct module *load_module(void __user *umod, | |||
| 2162 | 2180 | ||
| 2163 | add_kallsyms(mod, sechdrs, symindex, strindex, secstrings); | 2181 | add_kallsyms(mod, sechdrs, symindex, strindex, secstrings); |
| 2164 | 2182 | ||
| 2183 | if (!mod->taints) { | ||
| 2184 | struct mod_debug *debug; | ||
| 2185 | unsigned int num_debug; | ||
| 2186 | |||
| 2165 | #ifdef CONFIG_MARKERS | 2187 | #ifdef CONFIG_MARKERS |
| 2166 | if (!mod->taints) | ||
| 2167 | marker_update_probe_range(mod->markers, | 2188 | marker_update_probe_range(mod->markers, |
| 2168 | mod->markers + mod->num_markers); | 2189 | mod->markers + mod->num_markers); |
| 2169 | #endif | 2190 | #endif |
| 2191 | debug = section_objs(hdr, sechdrs, secstrings, "__verbose", | ||
| 2192 | sizeof(*debug), &num_debug); | ||
| 2193 | dynamic_printk_setup(debug, num_debug); | ||
| 2194 | |||
| 2195 | #ifdef CONFIG_TRACEPOINTS | ||
| 2196 | tracepoint_update_probe_range(mod->tracepoints, | ||
| 2197 | mod->tracepoints + mod->num_tracepoints); | ||
| 2198 | #endif | ||
| 2199 | } | ||
| 2200 | |||
| 2201 | /* sechdrs[0].sh_size is always zero */ | ||
| 2202 | mseg = section_objs(hdr, sechdrs, secstrings, "__mcount_loc", | ||
| 2203 | sizeof(*mseg), &num_mcount); | ||
| 2204 | ftrace_init_module(mseg, mseg + num_mcount); | ||
| 2205 | |||
| 2170 | err = module_finalize(hdr, sechdrs, mod); | 2206 | err = module_finalize(hdr, sechdrs, mod); |
| 2171 | if (err < 0) | 2207 | if (err < 0) |
| 2172 | goto cleanup; | 2208 | goto cleanup; |
| @@ -2190,30 +2226,24 @@ static noinline struct module *load_module(void __user *umod, | |||
| 2190 | set_fs(old_fs); | 2226 | set_fs(old_fs); |
| 2191 | 2227 | ||
| 2192 | mod->args = args; | 2228 | mod->args = args; |
| 2193 | if (obsparmindex) | 2229 | if (section_addr(hdr, sechdrs, secstrings, "__obsparm")) |
| 2194 | printk(KERN_WARNING "%s: Ignoring obsolete parameters\n", | 2230 | printk(KERN_WARNING "%s: Ignoring obsolete parameters\n", |
| 2195 | mod->name); | 2231 | mod->name); |
| 2196 | 2232 | ||
| 2197 | /* Now sew it into the lists so we can get lockdep and oops | 2233 | /* Now sew it into the lists so we can get lockdep and oops |
| 2198 | * info during argument parsing. Noone should access us, since | 2234 | * info during argument parsing. Noone should access us, since |
| 2199 | * strong_try_module_get() will fail. */ | 2235 | * strong_try_module_get() will fail. |
| 2200 | stop_machine(__link_module, mod, NULL); | 2236 | * lockdep/oops can run asynchronous, so use the RCU list insertion |
| 2201 | 2237 | * function to insert in a way safe to concurrent readers. | |
| 2202 | /* Size of section 0 is 0, so this works well if no params */ | 2238 | * The mutex protects against concurrent writers. |
| 2203 | err = parse_args(mod->name, mod->args, | 2239 | */ |
| 2204 | (struct kernel_param *) | 2240 | list_add_rcu(&mod->list, &modules); |
| 2205 | sechdrs[setupindex].sh_addr, | 2241 | |
| 2206 | sechdrs[setupindex].sh_size | 2242 | err = parse_args(mod->name, mod->args, kp, num_kp, NULL); |
| 2207 | / sizeof(struct kernel_param), | ||
| 2208 | NULL); | ||
| 2209 | if (err < 0) | 2243 | if (err < 0) |
| 2210 | goto unlink; | 2244 | goto unlink; |
| 2211 | 2245 | ||
| 2212 | err = mod_sysfs_setup(mod, | 2246 | err = mod_sysfs_setup(mod, kp, num_kp); |
| 2213 | (struct kernel_param *) | ||
| 2214 | sechdrs[setupindex].sh_addr, | ||
| 2215 | sechdrs[setupindex].sh_size | ||
| 2216 | / sizeof(struct kernel_param)); | ||
| 2217 | if (err < 0) | 2247 | if (err < 0) |
| 2218 | goto unlink; | 2248 | goto unlink; |
| 2219 | add_sect_attrs(mod, hdr->e_shnum, secstrings, sechdrs); | 2249 | add_sect_attrs(mod, hdr->e_shnum, secstrings, sechdrs); |
| @@ -2236,6 +2266,7 @@ static noinline struct module *load_module(void __user *umod, | |||
| 2236 | cleanup: | 2266 | cleanup: |
| 2237 | kobject_del(&mod->mkobj.kobj); | 2267 | kobject_del(&mod->mkobj.kobj); |
| 2238 | kobject_put(&mod->mkobj.kobj); | 2268 | kobject_put(&mod->mkobj.kobj); |
| 2269 | ftrace_release(mod->module_core, mod->core_size); | ||
| 2239 | free_unload: | 2270 | free_unload: |
| 2240 | module_unload_free(mod); | 2271 | module_unload_free(mod); |
| 2241 | module_free(mod, mod->module_init); | 2272 | module_free(mod, mod->module_init); |
| @@ -2401,7 +2432,7 @@ const char *module_address_lookup(unsigned long addr, | |||
| 2401 | const char *ret = NULL; | 2432 | const char *ret = NULL; |
| 2402 | 2433 | ||
| 2403 | preempt_disable(); | 2434 | preempt_disable(); |
| 2404 | list_for_each_entry(mod, &modules, list) { | 2435 | list_for_each_entry_rcu(mod, &modules, list) { |
| 2405 | if (within(addr, mod->module_init, mod->init_size) | 2436 | if (within(addr, mod->module_init, mod->init_size) |
| 2406 | || within(addr, mod->module_core, mod->core_size)) { | 2437 | || within(addr, mod->module_core, mod->core_size)) { |
| 2407 | if (modname) | 2438 | if (modname) |
| @@ -2424,7 +2455,7 @@ int lookup_module_symbol_name(unsigned long addr, char *symname) | |||
| 2424 | struct module *mod; | 2455 | struct module *mod; |
| 2425 | 2456 | ||
| 2426 | preempt_disable(); | 2457 | preempt_disable(); |
| 2427 | list_for_each_entry(mod, &modules, list) { | 2458 | list_for_each_entry_rcu(mod, &modules, list) { |
| 2428 | if (within(addr, mod->module_init, mod->init_size) || | 2459 | if (within(addr, mod->module_init, mod->init_size) || |
| 2429 | within(addr, mod->module_core, mod->core_size)) { | 2460 | within(addr, mod->module_core, mod->core_size)) { |
| 2430 | const char *sym; | 2461 | const char *sym; |
| @@ -2448,7 +2479,7 @@ int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, | |||
| 2448 | struct module *mod; | 2479 | struct module *mod; |
| 2449 | 2480 | ||
| 2450 | preempt_disable(); | 2481 | preempt_disable(); |
| 2451 | list_for_each_entry(mod, &modules, list) { | 2482 | list_for_each_entry_rcu(mod, &modules, list) { |
| 2452 | if (within(addr, mod->module_init, mod->init_size) || | 2483 | if (within(addr, mod->module_init, mod->init_size) || |
| 2453 | within(addr, mod->module_core, mod->core_size)) { | 2484 | within(addr, mod->module_core, mod->core_size)) { |
| 2454 | const char *sym; | 2485 | const char *sym; |
| @@ -2475,7 +2506,7 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, | |||
| 2475 | struct module *mod; | 2506 | struct module *mod; |
| 2476 | 2507 | ||
| 2477 | preempt_disable(); | 2508 | preempt_disable(); |
| 2478 | list_for_each_entry(mod, &modules, list) { | 2509 | list_for_each_entry_rcu(mod, &modules, list) { |
| 2479 | if (symnum < mod->num_symtab) { | 2510 | if (symnum < mod->num_symtab) { |
| 2480 | *value = mod->symtab[symnum].st_value; | 2511 | *value = mod->symtab[symnum].st_value; |
| 2481 | *type = mod->symtab[symnum].st_info; | 2512 | *type = mod->symtab[symnum].st_info; |
| @@ -2518,7 +2549,7 @@ unsigned long module_kallsyms_lookup_name(const char *name) | |||
| 2518 | ret = mod_find_symname(mod, colon+1); | 2549 | ret = mod_find_symname(mod, colon+1); |
| 2519 | *colon = ':'; | 2550 | *colon = ':'; |
| 2520 | } else { | 2551 | } else { |
| 2521 | list_for_each_entry(mod, &modules, list) | 2552 | list_for_each_entry_rcu(mod, &modules, list) |
| 2522 | if ((ret = mod_find_symname(mod, name)) != 0) | 2553 | if ((ret = mod_find_symname(mod, name)) != 0) |
| 2523 | break; | 2554 | break; |
| 2524 | } | 2555 | } |
| @@ -2527,23 +2558,6 @@ unsigned long module_kallsyms_lookup_name(const char *name) | |||
| 2527 | } | 2558 | } |
| 2528 | #endif /* CONFIG_KALLSYMS */ | 2559 | #endif /* CONFIG_KALLSYMS */ |
| 2529 | 2560 | ||
| 2530 | /* Called by the /proc file system to return a list of modules. */ | ||
| 2531 | static void *m_start(struct seq_file *m, loff_t *pos) | ||
| 2532 | { | ||
| 2533 | mutex_lock(&module_mutex); | ||
| 2534 | return seq_list_start(&modules, *pos); | ||
| 2535 | } | ||
| 2536 | |||
| 2537 | static void *m_next(struct seq_file *m, void *p, loff_t *pos) | ||
| 2538 | { | ||
| 2539 | return seq_list_next(p, &modules, pos); | ||
| 2540 | } | ||
| 2541 | |||
| 2542 | static void m_stop(struct seq_file *m, void *p) | ||
| 2543 | { | ||
| 2544 | mutex_unlock(&module_mutex); | ||
| 2545 | } | ||
| 2546 | |||
| 2547 | static char *module_flags(struct module *mod, char *buf) | 2561 | static char *module_flags(struct module *mod, char *buf) |
| 2548 | { | 2562 | { |
| 2549 | int bx = 0; | 2563 | int bx = 0; |
| @@ -2552,10 +2566,12 @@ static char *module_flags(struct module *mod, char *buf) | |||
| 2552 | mod->state == MODULE_STATE_GOING || | 2566 | mod->state == MODULE_STATE_GOING || |
| 2553 | mod->state == MODULE_STATE_COMING) { | 2567 | mod->state == MODULE_STATE_COMING) { |
| 2554 | buf[bx++] = '('; | 2568 | buf[bx++] = '('; |
| 2555 | if (mod->taints & TAINT_PROPRIETARY_MODULE) | 2569 | if (mod->taints & (1 << TAINT_PROPRIETARY_MODULE)) |
| 2556 | buf[bx++] = 'P'; | 2570 | buf[bx++] = 'P'; |
| 2557 | if (mod->taints & TAINT_FORCED_MODULE) | 2571 | if (mod->taints & (1 << TAINT_FORCED_MODULE)) |
| 2558 | buf[bx++] = 'F'; | 2572 | buf[bx++] = 'F'; |
| 2573 | if (mod->taints & (1 << TAINT_CRAP)) | ||
| 2574 | buf[bx++] = 'C'; | ||
| 2559 | /* | 2575 | /* |
| 2560 | * TAINT_FORCED_RMMOD: could be added. | 2576 | * TAINT_FORCED_RMMOD: could be added. |
| 2561 | * TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't | 2577 | * TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't |
| @@ -2575,6 +2591,24 @@ static char *module_flags(struct module *mod, char *buf) | |||
| 2575 | return buf; | 2591 | return buf; |
| 2576 | } | 2592 | } |
| 2577 | 2593 | ||
| 2594 | #ifdef CONFIG_PROC_FS | ||
| 2595 | /* Called by the /proc file system to return a list of modules. */ | ||
| 2596 | static void *m_start(struct seq_file *m, loff_t *pos) | ||
| 2597 | { | ||
| 2598 | mutex_lock(&module_mutex); | ||
| 2599 | return seq_list_start(&modules, *pos); | ||
| 2600 | } | ||
| 2601 | |||
| 2602 | static void *m_next(struct seq_file *m, void *p, loff_t *pos) | ||
| 2603 | { | ||
| 2604 | return seq_list_next(p, &modules, pos); | ||
| 2605 | } | ||
| 2606 | |||
| 2607 | static void m_stop(struct seq_file *m, void *p) | ||
| 2608 | { | ||
| 2609 | mutex_unlock(&module_mutex); | ||
| 2610 | } | ||
| 2611 | |||
| 2578 | static int m_show(struct seq_file *m, void *p) | 2612 | static int m_show(struct seq_file *m, void *p) |
| 2579 | { | 2613 | { |
| 2580 | struct module *mod = list_entry(p, struct module, list); | 2614 | struct module *mod = list_entry(p, struct module, list); |
| @@ -2605,13 +2639,33 @@ static int m_show(struct seq_file *m, void *p) | |||
| 2605 | Where refcount is a number or -, and deps is a comma-separated list | 2639 | Where refcount is a number or -, and deps is a comma-separated list |
| 2606 | of depends or -. | 2640 | of depends or -. |
| 2607 | */ | 2641 | */ |
| 2608 | const struct seq_operations modules_op = { | 2642 | static const struct seq_operations modules_op = { |
| 2609 | .start = m_start, | 2643 | .start = m_start, |
| 2610 | .next = m_next, | 2644 | .next = m_next, |
| 2611 | .stop = m_stop, | 2645 | .stop = m_stop, |
| 2612 | .show = m_show | 2646 | .show = m_show |
| 2613 | }; | 2647 | }; |
| 2614 | 2648 | ||
| 2649 | static int modules_open(struct inode *inode, struct file *file) | ||
| 2650 | { | ||
| 2651 | return seq_open(file, &modules_op); | ||
| 2652 | } | ||
| 2653 | |||
| 2654 | static const struct file_operations proc_modules_operations = { | ||
| 2655 | .open = modules_open, | ||
| 2656 | .read = seq_read, | ||
| 2657 | .llseek = seq_lseek, | ||
| 2658 | .release = seq_release, | ||
| 2659 | }; | ||
| 2660 | |||
| 2661 | static int __init proc_modules_init(void) | ||
| 2662 | { | ||
| 2663 | proc_create("modules", 0, NULL, &proc_modules_operations); | ||
| 2664 | return 0; | ||
| 2665 | } | ||
| 2666 | module_init(proc_modules_init); | ||
| 2667 | #endif | ||
| 2668 | |||
| 2615 | /* Given an address, look for it in the module exception tables. */ | 2669 | /* Given an address, look for it in the module exception tables. */ |
| 2616 | const struct exception_table_entry *search_module_extables(unsigned long addr) | 2670 | const struct exception_table_entry *search_module_extables(unsigned long addr) |
| 2617 | { | 2671 | { |
| @@ -2619,7 +2673,7 @@ const struct exception_table_entry *search_module_extables(unsigned long addr) | |||
| 2619 | struct module *mod; | 2673 | struct module *mod; |
| 2620 | 2674 | ||
| 2621 | preempt_disable(); | 2675 | preempt_disable(); |
| 2622 | list_for_each_entry(mod, &modules, list) { | 2676 | list_for_each_entry_rcu(mod, &modules, list) { |
| 2623 | if (mod->num_exentries == 0) | 2677 | if (mod->num_exentries == 0) |
| 2624 | continue; | 2678 | continue; |
| 2625 | 2679 | ||
| @@ -2645,7 +2699,7 @@ int is_module_address(unsigned long addr) | |||
| 2645 | 2699 | ||
| 2646 | preempt_disable(); | 2700 | preempt_disable(); |
| 2647 | 2701 | ||
| 2648 | list_for_each_entry(mod, &modules, list) { | 2702 | list_for_each_entry_rcu(mod, &modules, list) { |
| 2649 | if (within(addr, mod->module_core, mod->core_size)) { | 2703 | if (within(addr, mod->module_core, mod->core_size)) { |
| 2650 | preempt_enable(); | 2704 | preempt_enable(); |
| 2651 | return 1; | 2705 | return 1; |
| @@ -2666,7 +2720,7 @@ struct module *__module_text_address(unsigned long addr) | |||
| 2666 | if (addr < module_addr_min || addr > module_addr_max) | 2720 | if (addr < module_addr_min || addr > module_addr_max) |
| 2667 | return NULL; | 2721 | return NULL; |
| 2668 | 2722 | ||
| 2669 | list_for_each_entry(mod, &modules, list) | 2723 | list_for_each_entry_rcu(mod, &modules, list) |
| 2670 | if (within(addr, mod->module_init, mod->init_text_size) | 2724 | if (within(addr, mod->module_init, mod->init_text_size) |
| 2671 | || within(addr, mod->module_core, mod->core_text_size)) | 2725 | || within(addr, mod->module_core, mod->core_text_size)) |
| 2672 | return mod; | 2726 | return mod; |
| @@ -2691,8 +2745,11 @@ void print_modules(void) | |||
| 2691 | char buf[8]; | 2745 | char buf[8]; |
| 2692 | 2746 | ||
| 2693 | printk("Modules linked in:"); | 2747 | printk("Modules linked in:"); |
| 2694 | list_for_each_entry(mod, &modules, list) | 2748 | /* Most callers should already have preempt disabled, but make sure */ |
| 2749 | preempt_disable(); | ||
| 2750 | list_for_each_entry_rcu(mod, &modules, list) | ||
| 2695 | printk(" %s%s", mod->name, module_flags(mod, buf)); | 2751 | printk(" %s%s", mod->name, module_flags(mod, buf)); |
| 2752 | preempt_enable(); | ||
| 2696 | if (last_unloaded_module[0]) | 2753 | if (last_unloaded_module[0]) |
| 2697 | printk(" [last unloaded: %s]", last_unloaded_module); | 2754 | printk(" [last unloaded: %s]", last_unloaded_module); |
| 2698 | printk("\n"); | 2755 | printk("\n"); |
| @@ -2717,3 +2774,50 @@ void module_update_markers(void) | |||
| 2717 | mutex_unlock(&module_mutex); | 2774 | mutex_unlock(&module_mutex); |
| 2718 | } | 2775 | } |
| 2719 | #endif | 2776 | #endif |
| 2777 | |||
| 2778 | #ifdef CONFIG_TRACEPOINTS | ||
| 2779 | void module_update_tracepoints(void) | ||
| 2780 | { | ||
| 2781 | struct module *mod; | ||
| 2782 | |||
| 2783 | mutex_lock(&module_mutex); | ||
| 2784 | list_for_each_entry(mod, &modules, list) | ||
| 2785 | if (!mod->taints) | ||
| 2786 | tracepoint_update_probe_range(mod->tracepoints, | ||
| 2787 | mod->tracepoints + mod->num_tracepoints); | ||
| 2788 | mutex_unlock(&module_mutex); | ||
| 2789 | } | ||
| 2790 | |||
| 2791 | /* | ||
| 2792 | * Returns 0 if current not found. | ||
| 2793 | * Returns 1 if current found. | ||
| 2794 | */ | ||
| 2795 | int module_get_iter_tracepoints(struct tracepoint_iter *iter) | ||
| 2796 | { | ||
| 2797 | struct module *iter_mod; | ||
| 2798 | int found = 0; | ||
| 2799 | |||
| 2800 | mutex_lock(&module_mutex); | ||
| 2801 | list_for_each_entry(iter_mod, &modules, list) { | ||
| 2802 | if (!iter_mod->taints) { | ||
| 2803 | /* | ||
| 2804 | * Sorted module list | ||
| 2805 | */ | ||
| 2806 | if (iter_mod < iter->module) | ||
| 2807 | continue; | ||
| 2808 | else if (iter_mod > iter->module) | ||
| 2809 | iter->tracepoint = NULL; | ||
| 2810 | found = tracepoint_get_iter_range(&iter->tracepoint, | ||
| 2811 | iter_mod->tracepoints, | ||
| 2812 | iter_mod->tracepoints | ||
| 2813 | + iter_mod->num_tracepoints); | ||
| 2814 | if (found) { | ||
| 2815 | iter->module = iter_mod; | ||
| 2816 | break; | ||
| 2817 | } | ||
| 2818 | } | ||
| 2819 | } | ||
| 2820 | mutex_unlock(&module_mutex); | ||
| 2821 | return found; | ||
| 2822 | } | ||
| 2823 | #endif | ||
