Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'modules-for-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux

Pull module updates from Jessica Yu:
"Summary of modules changes for the 5.6 merge window:

- Add "MS" (SHF_MERGE|SHF_STRINGS) section flags to __ksymtab_strings
to indicate to the linker that it can perform string deduplication
(i.e., duplicate strings are reduced to a single copy in the string
table). This means any repeated namespace string would be merged to
just one entry in __ksymtab_strings.

- Various code cleanups and small fixes (fix small memleak in error
path, improve moduleparam docs, silence rcu warnings, improve error
logging)"

* tag 'modules-for-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux:
module.h: Annotate mod_kallsyms with __rcu
module: avoid setting info->name early in case we can fall back to info->mod->name
modsign: print module name along with error message
kernel/module: Fix memleak in module_add_modinfo_attrs()
export.h: reduce __ksymtab_strings string duplication by using "MS" section flags
moduleparam: fix kerneldoc
modules: lockdep: Suppress suspicious RCU usage warning

+119 -28
+5 -3
include/asm-generic/export.h
··· 27 27 .endm 28 28 29 29 /* 30 - * note on .section use: @progbits vs %progbits nastiness doesn't matter, 31 - * since we immediately emit into those sections anyway. 30 + * note on .section use: we specify progbits since usage of the "M" (SHF_MERGE) 31 + * section flag requires it. Use '%progbits' instead of '@progbits' since the 32 + * former apparently works on all arches according to the binutils source. 32 33 */ 34 + 33 35 .macro ___EXPORT_SYMBOL name,val,sec 34 36 #ifdef CONFIG_MODULES 35 37 .section ___ksymtab\sec+\name,"a" ··· 39 37 __ksymtab_\name: 40 38 __put \val, __kstrtab_\name 41 39 .previous 42 - .section __ksymtab_strings,"a" 40 + .section __ksymtab_strings,"aMS",%progbits,1 43 41 __kstrtab_\name: 44 42 .asciz "\name" 45 43 .previous
+23 -10
include/linux/export.h
··· 82 82 83 83 #else 84 84 85 - /* For every exported symbol, place a struct in the __ksymtab section */ 86 - #define ___EXPORT_SYMBOL(sym, sec, ns) \ 87 - extern typeof(sym) sym; \ 88 - __CRC_SYMBOL(sym, sec); \ 89 - static const char __kstrtab_##sym[] \ 90 - __attribute__((section("__ksymtab_strings"), used, aligned(1))) \ 91 - = #sym; \ 92 - static const char __kstrtabns_##sym[] \ 93 - __attribute__((section("__ksymtab_strings"), used, aligned(1))) \ 94 - = ns; \ 85 + /* 86 + * For every exported symbol, do the following: 87 + * 88 + * - If applicable, place a CRC entry in the __kcrctab section. 89 + * - Put the name of the symbol and namespace (empty string "" for none) in 90 + * __ksymtab_strings. 91 + * - Place a struct kernel_symbol entry in the __ksymtab section. 92 + * 93 + * note on .section use: we specify progbits since usage of the "M" (SHF_MERGE) 94 + * section flag requires it. Use '%progbits' instead of '@progbits' since the 95 + * former apparently works on all arches according to the binutils source. 96 + */ 97 + #define ___EXPORT_SYMBOL(sym, sec, ns) \ 98 + extern typeof(sym) sym; \ 99 + extern const char __kstrtab_##sym[]; \ 100 + extern const char __kstrtabns_##sym[]; \ 101 + __CRC_SYMBOL(sym, sec); \ 102 + asm(" .section \"__ksymtab_strings\",\"aMS\",%progbits,1 \n" \ 103 + "__kstrtab_" #sym ": \n" \ 104 + " .asciz \"" #sym "\" \n" \ 105 + "__kstrtabns_" #sym ": \n" \ 106 + " .asciz \"" ns "\" \n" \ 107 + " .previous \n"); \ 95 108 __KSYMTAB_ENTRY(sym, sec) 96 109 97 110 #endif
+1 -1
include/linux/module.h
··· 429 429 430 430 #ifdef CONFIG_KALLSYMS 431 431 /* Protected by RCU and/or module_mutex: use rcu_dereference() */ 432 - struct mod_kallsyms *kallsyms; 432 + struct mod_kallsyms __rcu *kallsyms; 433 433 struct mod_kallsyms core_kallsyms; 434 434 435 435 /* Section attributes */
+77 -5
include/linux/moduleparam.h
··· 128 128 129 129 /** 130 130 * module_param_unsafe - same as module_param but taints kernel 131 + * @name: the variable to alter, and exposed parameter name. 132 + * @type: the type of the parameter 133 + * @perm: visibility in sysfs. 131 134 */ 132 135 #define module_param_unsafe(name, type, perm) \ 133 136 module_param_named_unsafe(name, name, type, perm) ··· 153 150 154 151 /** 155 152 * module_param_named_unsafe - same as module_param_named but taints kernel 153 + * @name: a valid C identifier which is the parameter name. 154 + * @value: the actual lvalue to alter. 155 + * @type: the type of the parameter 156 + * @perm: visibility in sysfs. 156 157 */ 157 158 #define module_param_named_unsafe(name, value, type, perm) \ 158 159 param_check_##type(name, &(value)); \ ··· 167 160 * module_param_cb - general callback for a module/cmdline parameter 168 161 * @name: a valid C identifier which is the parameter name. 169 162 * @ops: the set & get operations for this parameter. 163 + * @arg: args for @ops 170 164 * @perm: visibility in sysfs. 171 165 * 172 166 * The ops can have NULL set or get functions. ··· 179 171 __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, \ 180 172 KERNEL_PARAM_FL_UNSAFE) 181 173 174 + #define __level_param_cb(name, ops, arg, perm, level) \ 175 + __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level, 0) 182 176 /** 183 - * <level>_param_cb - general callback for a module/cmdline parameter 184 - * to be evaluated before certain initcall level 177 + * core_param_cb - general callback for a module/cmdline parameter 178 + * to be evaluated before core initcall level 185 179 * @name: a valid C identifier which is the parameter name. 186 180 * @ops: the set & get operations for this parameter. 181 + * @arg: args for @ops 187 182 * @perm: visibility in sysfs. 188 183 * 189 184 * The ops can have NULL set or get functions. 190 185 */ 191 - #define __level_param_cb(name, ops, arg, perm, level) \ 192 - __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level, 0) 193 - 194 186 #define core_param_cb(name, ops, arg, perm) \ 195 187 __level_param_cb(name, ops, arg, perm, 1) 196 188 189 + /** 190 + * postcore_param_cb - general callback for a module/cmdline parameter 191 + * to be evaluated before postcore initcall level 192 + * @name: a valid C identifier which is the parameter name. 193 + * @ops: the set & get operations for this parameter. 194 + * @arg: args for @ops 195 + * @perm: visibility in sysfs. 196 + * 197 + * The ops can have NULL set or get functions. 198 + */ 197 199 #define postcore_param_cb(name, ops, arg, perm) \ 198 200 __level_param_cb(name, ops, arg, perm, 2) 199 201 202 + /** 203 + * arch_param_cb - general callback for a module/cmdline parameter 204 + * to be evaluated before arch initcall level 205 + * @name: a valid C identifier which is the parameter name. 206 + * @ops: the set & get operations for this parameter. 207 + * @arg: args for @ops 208 + * @perm: visibility in sysfs. 209 + * 210 + * The ops can have NULL set or get functions. 211 + */ 200 212 #define arch_param_cb(name, ops, arg, perm) \ 201 213 __level_param_cb(name, ops, arg, perm, 3) 202 214 215 + /** 216 + * subsys_param_cb - general callback for a module/cmdline parameter 217 + * to be evaluated before subsys initcall level 218 + * @name: a valid C identifier which is the parameter name. 219 + * @ops: the set & get operations for this parameter. 220 + * @arg: args for @ops 221 + * @perm: visibility in sysfs. 222 + * 223 + * The ops can have NULL set or get functions. 224 + */ 203 225 #define subsys_param_cb(name, ops, arg, perm) \ 204 226 __level_param_cb(name, ops, arg, perm, 4) 205 227 228 + /** 229 + * fs_param_cb - general callback for a module/cmdline parameter 230 + * to be evaluated before fs initcall level 231 + * @name: a valid C identifier which is the parameter name. 232 + * @ops: the set & get operations for this parameter. 233 + * @arg: args for @ops 234 + * @perm: visibility in sysfs. 235 + * 236 + * The ops can have NULL set or get functions. 237 + */ 206 238 #define fs_param_cb(name, ops, arg, perm) \ 207 239 __level_param_cb(name, ops, arg, perm, 5) 208 240 241 + /** 242 + * device_param_cb - general callback for a module/cmdline parameter 243 + * to be evaluated before device initcall level 244 + * @name: a valid C identifier which is the parameter name. 245 + * @ops: the set & get operations for this parameter. 246 + * @arg: args for @ops 247 + * @perm: visibility in sysfs. 248 + * 249 + * The ops can have NULL set or get functions. 250 + */ 209 251 #define device_param_cb(name, ops, arg, perm) \ 210 252 __level_param_cb(name, ops, arg, perm, 6) 211 253 254 + /** 255 + * late_param_cb - general callback for a module/cmdline parameter 256 + * to be evaluated before late initcall level 257 + * @name: a valid C identifier which is the parameter name. 258 + * @ops: the set & get operations for this parameter. 259 + * @arg: args for @ops 260 + * @perm: visibility in sysfs. 261 + * 262 + * The ops can have NULL set or get functions. 263 + */ 212 264 #define late_param_cb(name, ops, arg, perm) \ 213 265 __level_param_cb(name, ops, arg, perm, 7) 214 266 ··· 331 263 332 264 /** 333 265 * core_param_unsafe - same as core_param but taints kernel 266 + * @name: the name of the cmdline and sysfs parameter (often the same as var) 267 + * @var: the variable 268 + * @type: the type of the parameter 269 + * @perm: visibility in sysfs 334 270 */ 335 271 #define core_param_unsafe(name, var, type, perm) \ 336 272 param_check_##type(name, &(var)); \
+13 -9
kernel/module.c
··· 214 214 { 215 215 struct module *mod; 216 216 217 - list_for_each_entry_rcu(mod, &modules, list) { 217 + list_for_each_entry_rcu(mod, &modules, list, 218 + lockdep_is_held(&module_mutex)) { 218 219 if (within_module(addr, mod)) 219 220 return mod; 220 221 } ··· 449 448 if (each_symbol_in_section(arr, ARRAY_SIZE(arr), NULL, fn, data)) 450 449 return true; 451 450 452 - list_for_each_entry_rcu(mod, &modules, list) { 451 + list_for_each_entry_rcu(mod, &modules, list, 452 + lockdep_is_held(&module_mutex)) { 453 453 struct symsearch arr[] = { 454 454 { mod->syms, mod->syms + mod->num_syms, mod->crcs, 455 455 NOT_GPL_ONLY, false }, ··· 618 616 619 617 module_assert_mutex_or_preempt(); 620 618 621 - list_for_each_entry_rcu(mod, &modules, list) { 619 + list_for_each_entry_rcu(mod, &modules, list, 620 + lockdep_is_held(&module_mutex)) { 622 621 if (!even_unformed && mod->state == MODULE_STATE_UNFORMED) 623 622 continue; 624 623 if (strlen(mod->name) == len && !memcmp(mod->name, name, len)) ··· 1784 1781 error_out: 1785 1782 if (i > 0) 1786 1783 module_remove_modinfo_attrs(mod, --i); 1784 + else 1785 + kfree(mod->modinfo_attrs); 1787 1786 return error; 1788 1787 } 1789 1788 ··· 2839 2834 reason = "Loading of module with unavailable key"; 2840 2835 decide: 2841 2836 if (is_module_sig_enforced()) { 2842 - pr_notice("%s is rejected\n", reason); 2837 + pr_notice("%s: %s is rejected\n", info->name, reason); 2843 2838 return -EKEYREJECTED; 2844 2839 } 2845 2840 ··· 3016 3011 3017 3012 /* Try to find a name early so we can log errors with a module name */ 3018 3013 info->index.info = find_sec(info, ".modinfo"); 3019 - if (!info->index.info) 3020 - info->name = "(missing .modinfo section)"; 3021 - else 3014 + if (info->index.info) 3022 3015 info->name = get_modinfo(info, "name"); 3023 3016 3024 3017 /* Find internal symbols and strings. */ ··· 3031 3028 } 3032 3029 3033 3030 if (info->index.sym == 0) { 3034 - pr_warn("%s: module has no symbols (stripped?)\n", info->name); 3031 + pr_warn("%s: module has no symbols (stripped?)\n", 3032 + info->name ?: "(missing .modinfo section or name field)"); 3035 3033 return -ENOEXEC; 3036 3034 } 3037 3035 3038 3036 info->index.mod = find_sec(info, ".gnu.linkonce.this_module"); 3039 3037 if (!info->index.mod) { 3040 3038 pr_warn("%s: No module found in object\n", 3041 - info->name ?: "(missing .modinfo name field)"); 3039 + info->name ?: "(missing .modinfo section or name field)"); 3042 3040 return -ENOEXEC; 3043 3041 } 3044 3042 /* This is temporary: point mod into copy of data. */