Modules updates for v4.14
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 Signed-off-by: Jessica Yu <jeyu@kernel.org> -----BEGIN PGP SIGNATURE----- iQIcBAABCgAGBQJZuOmrAAoJEMBFfjjOO8FySvAP/2SLHR+HLU53jbUdQTZF4cYp 2PitELmICHSOmBC2frBsZiy1Dnzh2LDHM4gEenWYkk2nUfpPbURYi+43xbUKugmR I1pwr5aanibogCfu2C/xi57RonxkS0l/BsFOorFPNNqH8H24rsZaUfNMUtuOsh3D K1KjM/N5BTncVF2wdXogPl1mlngtzM1Nvu02EbmltJYlTmwv+BlHc6xu4677sW6u zeZ1gBt/oeKIgenYphL/NmbdI6veV8LVUd5EzcK7QQCbp2Pf/gAKQakQauDHNmRp WQtNhTksvbKS1qmTX8Qf4UE1i9Sfzg1kokg3AMIsIFJMFCN+WkGz38yTzoNDRUgi afv9Z0XPgBfoGvwZ2RCPtZqZXC/OHEUbhfnXTFPnjIQAHTrNWNGzwj89RXKTCTLz dCgA4zUZ9DgGyve2iqDvgWSn+Tb2RevPhajzepEcpz+UNUdXQRJHdcVEfLXWN/1u dqYXiLWSIcCfqIRl4RDwYeTSbeY9GrLkLzHsL7YSGVL//jubEoKjsSEr2cLsngtr 953jbA+El2DwnPJDoeEAOIN0XBg4arA9Roj4eIBeqG7y/BGpIn0HI+fZui5zxAoR 1fWhmqG5Uvoz/hzWwWOQTu3cQP2fgyJ5Jzg784oLjF8LwCrZYWc+yDdO+J5WywFJ iA7DBkZoajKFQjf9SZkU =oTCM -----END PGP SIGNATURE----- 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
This commit is contained in:
commit
4791bcccf8
|
@ -209,7 +209,7 @@ extern void cleanup_module(void);
|
|||
#ifdef MODULE
|
||||
/* Creates an alias so file2alias.c can find device table. */
|
||||
#define MODULE_DEVICE_TABLE(type, name) \
|
||||
extern const typeof(name) __mod_##type##__##name##_device_table \
|
||||
extern typeof(name) __mod_##type##__##name##_device_table \
|
||||
__attribute__ ((unused, alias(__stringify(name))))
|
||||
#else /* !MODULE */
|
||||
#define MODULE_DEVICE_TABLE(type, name)
|
||||
|
|
|
@ -2707,21 +2707,21 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
|
|||
}
|
||||
#endif /* CONFIG_KALLSYMS */
|
||||
|
||||
static void dynamic_debug_setup(struct _ddebug *debug, unsigned int num)
|
||||
static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsigned int num)
|
||||
{
|
||||
if (!debug)
|
||||
return;
|
||||
#ifdef CONFIG_DYNAMIC_DEBUG
|
||||
if (ddebug_add_module(debug, num, debug->modname))
|
||||
if (ddebug_add_module(debug, num, mod->name))
|
||||
pr_err("dynamic debug error adding module: %s\n",
|
||||
debug->modname);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void dynamic_debug_remove(struct _ddebug *debug)
|
||||
static void dynamic_debug_remove(struct module *mod, struct _ddebug *debug)
|
||||
{
|
||||
if (debug)
|
||||
ddebug_remove_module(debug->modname);
|
||||
ddebug_remove_module(mod->name);
|
||||
}
|
||||
|
||||
void * __weak module_alloc(unsigned long size)
|
||||
|
@ -3715,7 +3715,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
|
|||
goto free_arch_cleanup;
|
||||
}
|
||||
|
||||
dynamic_debug_setup(info->debug, info->num_debug);
|
||||
dynamic_debug_setup(mod, info->debug, info->num_debug);
|
||||
|
||||
/* Ftrace init must be called in the MODULE_STATE_UNFORMED state */
|
||||
ftrace_module_init(mod);
|
||||
|
@ -3779,7 +3779,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
|
|||
module_disable_nx(mod);
|
||||
|
||||
ddebug_cleanup:
|
||||
dynamic_debug_remove(info->debug);
|
||||
dynamic_debug_remove(mod, info->debug);
|
||||
synchronize_sched();
|
||||
kfree(mod->args);
|
||||
free_arch_cleanup:
|
||||
|
|
|
@ -47,6 +47,12 @@ enum export {
|
|||
export_unused_gpl, export_gpl_future, export_unknown
|
||||
};
|
||||
|
||||
/* In kernel, this size is defined in linux/module.h;
|
||||
* here we use Elf_Addr instead of long for covering cross-compile
|
||||
*/
|
||||
|
||||
#define MODULE_NAME_LEN (64 - sizeof(Elf_Addr))
|
||||
|
||||
#define PRINTF __attribute__ ((format (printf, 1, 2)))
|
||||
|
||||
PRINTF void fatal(const char *fmt, ...)
|
||||
|
@ -2111,6 +2117,23 @@ static void check_exports(struct module *mod)
|
|||
}
|
||||
}
|
||||
|
||||
static int check_modname_len(struct module *mod)
|
||||
{
|
||||
const char *mod_name;
|
||||
|
||||
mod_name = strrchr(mod->name, '/');
|
||||
if (mod_name == NULL)
|
||||
mod_name = mod->name;
|
||||
else
|
||||
mod_name++;
|
||||
if (strlen(mod_name) >= MODULE_NAME_LEN) {
|
||||
merror("module name is too long [%s.ko]\n", mod->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Header for the generated file
|
||||
**/
|
||||
|
@ -2150,11 +2173,6 @@ static void add_staging_flag(struct buffer *b, const char *name)
|
|||
buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n");
|
||||
}
|
||||
|
||||
/* In kernel, this size is defined in linux/module.h;
|
||||
* here we use Elf_Addr instead of long for covering cross-compile
|
||||
*/
|
||||
#define MODULE_NAME_LEN (64 - sizeof(Elf_Addr))
|
||||
|
||||
/**
|
||||
* Record CRCs for unresolved symbols
|
||||
**/
|
||||
|
@ -2485,6 +2503,7 @@ int main(int argc, char **argv)
|
|||
|
||||
buf.pos = 0;
|
||||
|
||||
err |= check_modname_len(mod);
|
||||
add_header(&buf, mod);
|
||||
add_intree_flag(&buf, !external_module);
|
||||
add_staging_flag(&buf, mod->name);
|
||||
|
|
Loading…
Reference in New Issue