diff options
| -rw-r--r-- | kernel/module.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/kernel/module.c b/kernel/module.c index 794ebe8e878d..6dbfad415d51 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
| @@ -3392,9 +3392,6 @@ static int complete_formation(struct module *mod, struct load_info *info) | |||
| 3392 | mod->state = MODULE_STATE_COMING; | 3392 | mod->state = MODULE_STATE_COMING; |
| 3393 | mutex_unlock(&module_mutex); | 3393 | mutex_unlock(&module_mutex); |
| 3394 | 3394 | ||
| 3395 | ftrace_module_enable(mod); | ||
| 3396 | blocking_notifier_call_chain(&module_notify_list, | ||
| 3397 | MODULE_STATE_COMING, mod); | ||
| 3398 | return 0; | 3395 | return 0; |
| 3399 | 3396 | ||
| 3400 | out: | 3397 | out: |
| @@ -3402,6 +3399,14 @@ out: | |||
| 3402 | return err; | 3399 | return err; |
| 3403 | } | 3400 | } |
| 3404 | 3401 | ||
| 3402 | static int prepare_coming_module(struct module *mod) | ||
| 3403 | { | ||
| 3404 | ftrace_module_enable(mod); | ||
| 3405 | blocking_notifier_call_chain(&module_notify_list, | ||
| 3406 | MODULE_STATE_COMING, mod); | ||
| 3407 | return 0; | ||
| 3408 | } | ||
| 3409 | |||
| 3405 | static int unknown_module_param_cb(char *param, char *val, const char *modname, | 3410 | static int unknown_module_param_cb(char *param, char *val, const char *modname, |
| 3406 | void *arg) | 3411 | void *arg) |
| 3407 | { | 3412 | { |
| @@ -3516,13 +3521,17 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
| 3516 | if (err) | 3521 | if (err) |
| 3517 | goto ddebug_cleanup; | 3522 | goto ddebug_cleanup; |
| 3518 | 3523 | ||
| 3524 | err = prepare_coming_module(mod); | ||
| 3525 | if (err) | ||
| 3526 | goto bug_cleanup; | ||
| 3527 | |||
| 3519 | /* Module is ready to execute: parsing args may do that. */ | 3528 | /* Module is ready to execute: parsing args may do that. */ |
| 3520 | after_dashes = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, | 3529 | after_dashes = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, |
| 3521 | -32768, 32767, mod, | 3530 | -32768, 32767, mod, |
| 3522 | unknown_module_param_cb); | 3531 | unknown_module_param_cb); |
| 3523 | if (IS_ERR(after_dashes)) { | 3532 | if (IS_ERR(after_dashes)) { |
| 3524 | err = PTR_ERR(after_dashes); | 3533 | err = PTR_ERR(after_dashes); |
| 3525 | goto bug_cleanup; | 3534 | goto coming_cleanup; |
| 3526 | } else if (after_dashes) { | 3535 | } else if (after_dashes) { |
| 3527 | pr_warn("%s: parameters '%s' after `--' ignored\n", | 3536 | pr_warn("%s: parameters '%s' after `--' ignored\n", |
| 3528 | mod->name, after_dashes); | 3537 | mod->name, after_dashes); |
| @@ -3531,7 +3540,7 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
| 3531 | /* Link in to syfs. */ | 3540 | /* Link in to syfs. */ |
| 3532 | err = mod_sysfs_setup(mod, info, mod->kp, mod->num_kp); | 3541 | err = mod_sysfs_setup(mod, info, mod->kp, mod->num_kp); |
| 3533 | if (err < 0) | 3542 | if (err < 0) |
| 3534 | goto bug_cleanup; | 3543 | goto coming_cleanup; |
| 3535 | 3544 | ||
| 3536 | /* Get rid of temporary copy. */ | 3545 | /* Get rid of temporary copy. */ |
| 3537 | free_copy(info); | 3546 | free_copy(info); |
| @@ -3541,15 +3550,16 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
| 3541 | 3550 | ||
| 3542 | return do_init_module(mod); | 3551 | return do_init_module(mod); |
| 3543 | 3552 | ||
| 3553 | coming_cleanup: | ||
| 3554 | blocking_notifier_call_chain(&module_notify_list, | ||
| 3555 | MODULE_STATE_GOING, mod); | ||
| 3556 | |||
| 3544 | bug_cleanup: | 3557 | bug_cleanup: |
| 3545 | /* module_bug_cleanup needs module_mutex protection */ | 3558 | /* module_bug_cleanup needs module_mutex protection */ |
| 3546 | mutex_lock(&module_mutex); | 3559 | mutex_lock(&module_mutex); |
| 3547 | module_bug_cleanup(mod); | 3560 | module_bug_cleanup(mod); |
| 3548 | mutex_unlock(&module_mutex); | 3561 | mutex_unlock(&module_mutex); |
| 3549 | 3562 | ||
| 3550 | blocking_notifier_call_chain(&module_notify_list, | ||
| 3551 | MODULE_STATE_GOING, mod); | ||
| 3552 | |||
| 3553 | /* we can't deallocate the module until we clear memory protection */ | 3563 | /* we can't deallocate the module until we clear memory protection */ |
| 3554 | module_disable_ro(mod); | 3564 | module_disable_ro(mod); |
| 3555 | module_disable_nx(mod); | 3565 | module_disable_nx(mod); |
