aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/module.c')
-rw-r--r--kernel/module.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 35f7de00bf0d..0a049837008e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2216,6 +2216,10 @@ static noinline struct module *load_module(void __user *umod,
2216 mod->unused_gpl_crcs = section_addr(hdr, sechdrs, secstrings, 2216 mod->unused_gpl_crcs = section_addr(hdr, sechdrs, secstrings,
2217 "__kcrctab_unused_gpl"); 2217 "__kcrctab_unused_gpl");
2218#endif 2218#endif
2219#ifdef CONFIG_CONSTRUCTORS
2220 mod->ctors = section_objs(hdr, sechdrs, secstrings, ".ctors",
2221 sizeof(*mod->ctors), &mod->num_ctors);
2222#endif
2219 2223
2220#ifdef CONFIG_MARKERS 2224#ifdef CONFIG_MARKERS
2221 mod->markers = section_objs(hdr, sechdrs, secstrings, "__markers", 2225 mod->markers = section_objs(hdr, sechdrs, secstrings, "__markers",
@@ -2389,6 +2393,17 @@ static noinline struct module *load_module(void __user *umod,
2389 goto free_hdr; 2393 goto free_hdr;
2390} 2394}
2391 2395
2396/* Call module constructors. */
2397static void do_mod_ctors(struct module *mod)
2398{
2399#ifdef CONFIG_CONSTRUCTORS
2400 unsigned long i;
2401
2402 for (i = 0; i < mod->num_ctors; i++)
2403 mod->ctors[i]();
2404#endif
2405}
2406
2392/* This is where the real work happens */ 2407/* This is where the real work happens */
2393SYSCALL_DEFINE3(init_module, void __user *, umod, 2408SYSCALL_DEFINE3(init_module, void __user *, umod,
2394 unsigned long, len, const char __user *, uargs) 2409 unsigned long, len, const char __user *, uargs)
@@ -2417,6 +2432,7 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
2417 blocking_notifier_call_chain(&module_notify_list, 2432 blocking_notifier_call_chain(&module_notify_list,
2418 MODULE_STATE_COMING, mod); 2433 MODULE_STATE_COMING, mod);
2419 2434
2435 do_mod_ctors(mod);
2420 /* Start the module */ 2436 /* Start the module */
2421 if (mod->init != NULL) 2437 if (mod->init != NULL)
2422 ret = do_one_initcall(mod->init); 2438 ret = do_one_initcall(mod->init);
@@ -2435,9 +2451,9 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
2435 return ret; 2451 return ret;
2436 } 2452 }
2437 if (ret > 0) { 2453 if (ret > 0) {
2438 printk(KERN_WARNING "%s: '%s'->init suspiciously returned %d, " 2454 printk(KERN_WARNING
2439 "it should follow 0/-E convention\n" 2455"%s: '%s'->init suspiciously returned %d, it should follow 0/-E convention\n"
2440 KERN_WARNING "%s: loading module anyway...\n", 2456"%s: loading module anyway...\n",
2441 __func__, mod->name, ret, 2457 __func__, mod->name, ret,
2442 __func__); 2458 __func__);
2443 dump_stack(); 2459 dump_stack();
@@ -2455,6 +2471,7 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
2455 mutex_lock(&module_mutex); 2471 mutex_lock(&module_mutex);
2456 /* Drop initial reference. */ 2472 /* Drop initial reference. */
2457 module_put(mod); 2473 module_put(mod);
2474 trim_init_extable(mod);
2458 module_free(mod, mod->module_init); 2475 module_free(mod, mod->module_init);
2459 mod->module_init = NULL; 2476 mod->module_init = NULL;
2460 mod->init_size = 0; 2477 mod->init_size = 0;
@@ -2898,7 +2915,7 @@ void print_modules(void)
2898 struct module *mod; 2915 struct module *mod;
2899 char buf[8]; 2916 char buf[8];
2900 2917
2901 printk("Modules linked in:"); 2918 printk(KERN_DEFAULT "Modules linked in:");
2902 /* Most callers should already have preempt disabled, but make sure */ 2919 /* Most callers should already have preempt disabled, but make sure */
2903 preempt_disable(); 2920 preempt_disable();
2904 list_for_each_entry_rcu(mod, &modules, list) 2921 list_for_each_entry_rcu(mod, &modules, list)