History

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

Linus Torvalds committed 9 years ago

Commit 4791bcc2 parents 3882a73 0bf8bf53 files · +31 −12Browse files

Unified · Split

3 files
  1. include/linux/module.h +1 −1
  2. kernel/module.c +6 −6
  3. scripts/mod/modpost.c +24 −5
include/linux/module.h+1−1
@@ -209,7 +209,7 @@ extern void cleanup_module(void); · 208 unmodified lines
209209 #ifdef MODULE
210210 /* Creates an alias so file2alias.c can find device table. */
211211 #define MODULE_DEVICE_TABLE(type, name) \
212−extern const typeof(name) __mod_##type##__##name##_device_table \
212+extern typeof(name) __mod_##type##__##name##_device_table \
213213 __attribute__ ((unused, alias(__stringify(name))))
214214 #else /* !MODULE */
215215 #define MODULE_DEVICE_TABLE(type, name)
kernel/module.c+6−6
@@ -2707,21 +2707,21 @@ static void add_kallsyms(struct module *mod, const struct load_info *info) · 2706 unmodified lines
27072707 }
27082708 #endif /* CONFIG_KALLSYMS */
27092709
2710−static void dynamic_debug_setup(struct _ddebug *debug, unsigned int num)
2710+static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsigned int num)
27112711 {
27122712 if (!debug)
27132713 return;
27142714 #ifdef CONFIG_DYNAMIC_DEBUG
2715− if (ddebug_add_module(debug, num, debug->modname))
2715+ if (ddebug_add_module(debug, num, mod->name))
27162716 pr_err("dynamic debug error adding module: %s\n",
27172717 debug->modname);
27182718 #endif
27192719 }
27202720
2721−static void dynamic_debug_remove(struct _ddebug *debug)
2721+static void dynamic_debug_remove(struct module *mod, struct _ddebug *debug)
27222722 {
27232723 if (debug)
2724− ddebug_remove_module(debug->modname);
2724+ ddebug_remove_module(mod->name);
27252725 }
27262726
27272727 void * __weak module_alloc(unsigned long size)
@@ -3715,7 +3715,7 @@ static int load_module(struct load_info *info, const char __user *uargs, · 987 unmodified lines
37153715 goto free_arch_cleanup;
37163716 }
37173717
3718− dynamic_debug_setup(info->debug, info->num_debug);
3718+ dynamic_debug_setup(mod, info->debug, info->num_debug);
37193719
37203720 /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */
37213721 ftrace_module_init(mod);
@@ -3779,7 +3779,7 @@ static int load_module(struct load_info *info, const char __user *uargs, · 57 unmodified lines
37793779 module_disable_nx(mod);
37803780
37813781 ddebug_cleanup:
3782− dynamic_debug_remove(info->debug);
3782+ dynamic_debug_remove(mod, info->debug);
37833783 synchronize_sched();
37843784 kfree(mod->args);
37853785 free_arch_cleanup:
scripts/mod/modpost.c+24−5
@@ -47,6 +47,12 @@ enum export { · 46 unmodified lines
4747 export_unused_gpl, export_gpl_future, export_unknown
4848 };
4949
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+
5056 #define PRINTF __attribute__ ((format (printf, 1, 2)))
5157
5258 PRINTF void fatal(const char *fmt, ...)
@@ -2111,6 +2117,23 @@ static void check_exports(struct module *mod) · 2058 unmodified lines
21112117 }
21122118 }
21132119
2120+static int check_modname_len(struct module *mod)
2121+{
2122+ const char *mod_name;
2123+
2124+ mod_name = strrchr(mod->name, '/');
2125+ if (mod_name == NULL)
2126+ mod_name = mod->name;
2127+ else
2128+ mod_name++;
2129+ if (strlen(mod_name) >= MODULE_NAME_LEN) {
2130+ merror("module name is too long [%s.ko]\n", mod->name);
2131+ return 1;
2132+ }
2133+
2134+ return 0;
2135+}
2136+
21142137 /**
21152138 * Header for the generated file
21162139 **/
@@ -2150,11 +2173,6 @@ static void add_staging_flag(struct buffer *b, const char *name) · 33 unmodified lines
21502173 buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n");
21512174 }
21522175
2153−/* In kernel, this size is defined in linux/module.h;
2154− * here we use Elf_Addr instead of long for covering cross-compile
2155− */
2156−#define MODULE_NAME_LEN (64 - sizeof(Elf_Addr))
2157−
21582176 /**
21592177 * Record CRCs for unresolved symbols
21602178 **/
@@ -2485,6 +2503,7 @@ int main(int argc, char **argv) · 324 unmodified lines
24852503
24862504 buf.pos = 0;
24872505
2506+ err |= check_modname_len(mod);
24882507 add_header(&buf, mod);
24892508 add_intree_flag(&buf, !external_module);
24902509 add_staging_flag(&buf, mod->name);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t