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

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

- minor code cleanups and fixes

- modpost: avoid building modules that have names that exceed the
size of the name field in struct module"

* tag 'modules-for-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux:
module: Remove const attribute from alias for MODULE_DEVICE_TABLE
module: fix ddebug_remove_module()
modpost: abort if module name is too long

+31 -12
+1 -1
include/linux/module.h
··· 209 #ifdef MODULE 210 /* Creates an alias so file2alias.c can find device table. */ 211 #define MODULE_DEVICE_TABLE(type, name) \ 212 - extern const typeof(name) __mod_##type##__##name##_device_table \ 213 __attribute__ ((unused, alias(__stringify(name)))) 214 #else /* !MODULE */ 215 #define MODULE_DEVICE_TABLE(type, name)
··· 209 #ifdef MODULE 210 /* Creates an alias so file2alias.c can find device table. */ 211 #define MODULE_DEVICE_TABLE(type, name) \ 212 + extern typeof(name) __mod_##type##__##name##_device_table \ 213 __attribute__ ((unused, alias(__stringify(name)))) 214 #else /* !MODULE */ 215 #define MODULE_DEVICE_TABLE(type, name)
+6 -6
kernel/module.c
··· 2707 } 2708 #endif /* CONFIG_KALLSYMS */ 2709 2710 - static void dynamic_debug_setup(struct _ddebug *debug, unsigned int num) 2711 { 2712 if (!debug) 2713 return; 2714 #ifdef CONFIG_DYNAMIC_DEBUG 2715 - if (ddebug_add_module(debug, num, debug->modname)) 2716 pr_err("dynamic debug error adding module: %s\n", 2717 debug->modname); 2718 #endif 2719 } 2720 2721 - static void dynamic_debug_remove(struct _ddebug *debug) 2722 { 2723 if (debug) 2724 - ddebug_remove_module(debug->modname); 2725 } 2726 2727 void * __weak module_alloc(unsigned long size) ··· 3715 goto free_arch_cleanup; 3716 } 3717 3718 - dynamic_debug_setup(info->debug, info->num_debug); 3719 3720 /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */ 3721 ftrace_module_init(mod); ··· 3779 module_disable_nx(mod); 3780 3781 ddebug_cleanup: 3782 - dynamic_debug_remove(info->debug); 3783 synchronize_sched(); 3784 kfree(mod->args); 3785 free_arch_cleanup:
··· 2707 } 2708 #endif /* CONFIG_KALLSYMS */ 2709 2710 + static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsigned int num) 2711 { 2712 if (!debug) 2713 return; 2714 #ifdef CONFIG_DYNAMIC_DEBUG 2715 + if (ddebug_add_module(debug, num, mod->name)) 2716 pr_err("dynamic debug error adding module: %s\n", 2717 debug->modname); 2718 #endif 2719 } 2720 2721 + static void dynamic_debug_remove(struct module *mod, struct _ddebug *debug) 2722 { 2723 if (debug) 2724 + ddebug_remove_module(mod->name); 2725 } 2726 2727 void * __weak module_alloc(unsigned long size) ··· 3715 goto free_arch_cleanup; 3716 } 3717 3718 + dynamic_debug_setup(mod, info->debug, info->num_debug); 3719 3720 /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */ 3721 ftrace_module_init(mod); ··· 3779 module_disable_nx(mod); 3780 3781 ddebug_cleanup: 3782 + dynamic_debug_remove(mod, info->debug); 3783 synchronize_sched(); 3784 kfree(mod->args); 3785 free_arch_cleanup:
+24 -5
scripts/mod/modpost.c
··· 47 export_unused_gpl, export_gpl_future, export_unknown 48 }; 49 50 #define PRINTF __attribute__ ((format (printf, 1, 2))) 51 52 PRINTF void fatal(const char *fmt, ...) ··· 2117 } 2118 } 2119 2120 /** 2121 * Header for the generated file 2122 **/ ··· 2172 if (strncmp(staging_dir, name, strlen(staging_dir)) == 0) 2173 buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); 2174 } 2175 - 2176 - /* In kernel, this size is defined in linux/module.h; 2177 - * here we use Elf_Addr instead of long for covering cross-compile 2178 - */ 2179 - #define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) 2180 2181 /** 2182 * Record CRCs for unresolved symbols ··· 2503 2504 buf.pos = 0; 2505 2506 add_header(&buf, mod); 2507 add_intree_flag(&buf, !external_module); 2508 add_staging_flag(&buf, mod->name);
··· 47 export_unused_gpl, export_gpl_future, export_unknown 48 }; 49 50 + /* In kernel, this size is defined in linux/module.h; 51 + * here we use Elf_Addr instead of long for covering cross-compile 52 + */ 53 + 54 + #define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) 55 + 56 #define PRINTF __attribute__ ((format (printf, 1, 2))) 57 58 PRINTF void fatal(const char *fmt, ...) ··· 2111 } 2112 } 2113 2114 + static int check_modname_len(struct module *mod) 2115 + { 2116 + const char *mod_name; 2117 + 2118 + mod_name = strrchr(mod->name, '/'); 2119 + if (mod_name == NULL) 2120 + mod_name = mod->name; 2121 + else 2122 + mod_name++; 2123 + if (strlen(mod_name) >= MODULE_NAME_LEN) { 2124 + merror("module name is too long [%s.ko]\n", mod->name); 2125 + return 1; 2126 + } 2127 + 2128 + return 0; 2129 + } 2130 + 2131 /** 2132 * Header for the generated file 2133 **/ ··· 2149 if (strncmp(staging_dir, name, strlen(staging_dir)) == 0) 2150 buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); 2151 } 2152 2153 /** 2154 * Record CRCs for unresolved symbols ··· 2485 2486 buf.pos = 0; 2487 2488 + err |= check_modname_len(mod); 2489 add_header(&buf, mod); 2490 add_intree_flag(&buf, !external_module); 2491 add_staging_flag(&buf, mod->name);