diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2014-05-13 21:24:19 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2014-05-13 21:25:47 -0400 |
commit | 4982223e51e8ea9d09bb33c8323b5ec1877b2b51 (patch) | |
tree | c944679cbc1b341771eceea899f0cccdf64c4c64 /kernel/module.c | |
parent | de5109898a8a0cb001abcb6916bef4efa32bf39b (diff) |
module: set nx before marking module MODULE_STATE_COMING.
We currently set RO & NX on modules very late: after we move them from
MODULE_STATE_UNFORMED to MODULE_STATE_COMING, and after we call
parse_args() (which can exec code in the module).
Much better is to do it in complete_formation() and then call
the notifier.
This means that the notifiers will be called on a module which
is already RO & NX, so that may cause problems (ftrace already
changed so they're unaffected).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/kernel/module.c b/kernel/module.c index 66e4e0d260a9..f944c72d3c8a 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -3023,21 +3023,6 @@ static int do_init_module(struct module *mod) | |||
3023 | */ | 3023 | */ |
3024 | current->flags &= ~PF_USED_ASYNC; | 3024 | current->flags &= ~PF_USED_ASYNC; |
3025 | 3025 | ||
3026 | blocking_notifier_call_chain(&module_notify_list, | ||
3027 | MODULE_STATE_COMING, mod); | ||
3028 | |||
3029 | /* Set RO and NX regions for core */ | ||
3030 | set_section_ro_nx(mod->module_core, | ||
3031 | mod->core_text_size, | ||
3032 | mod->core_ro_size, | ||
3033 | mod->core_size); | ||
3034 | |||
3035 | /* Set RO and NX regions for init */ | ||
3036 | set_section_ro_nx(mod->module_init, | ||
3037 | mod->init_text_size, | ||
3038 | mod->init_ro_size, | ||
3039 | mod->init_size); | ||
3040 | |||
3041 | do_mod_ctors(mod); | 3026 | do_mod_ctors(mod); |
3042 | /* Start the module */ | 3027 | /* Start the module */ |
3043 | if (mod->init != NULL) | 3028 | if (mod->init != NULL) |
@@ -3168,9 +3153,26 @@ static int complete_formation(struct module *mod, struct load_info *info) | |||
3168 | /* This relies on module_mutex for list integrity. */ | 3153 | /* This relies on module_mutex for list integrity. */ |
3169 | module_bug_finalize(info->hdr, info->sechdrs, mod); | 3154 | module_bug_finalize(info->hdr, info->sechdrs, mod); |
3170 | 3155 | ||
3156 | /* Set RO and NX regions for core */ | ||
3157 | set_section_ro_nx(mod->module_core, | ||
3158 | mod->core_text_size, | ||
3159 | mod->core_ro_size, | ||
3160 | mod->core_size); | ||
3161 | |||
3162 | /* Set RO and NX regions for init */ | ||
3163 | set_section_ro_nx(mod->module_init, | ||
3164 | mod->init_text_size, | ||
3165 | mod->init_ro_size, | ||
3166 | mod->init_size); | ||
3167 | |||
3171 | /* Mark state as coming so strong_try_module_get() ignores us, | 3168 | /* Mark state as coming so strong_try_module_get() ignores us, |
3172 | * but kallsyms etc. can see us. */ | 3169 | * but kallsyms etc. can see us. */ |
3173 | mod->state = MODULE_STATE_COMING; | 3170 | mod->state = MODULE_STATE_COMING; |
3171 | mutex_unlock(&module_mutex); | ||
3172 | |||
3173 | blocking_notifier_call_chain(&module_notify_list, | ||
3174 | MODULE_STATE_COMING, mod); | ||
3175 | return 0; | ||
3174 | 3176 | ||
3175 | out: | 3177 | out: |
3176 | mutex_unlock(&module_mutex); | 3178 | mutex_unlock(&module_mutex); |