diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-01-20 19:44:28 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-01-20 19:44:28 -0500 |
commit | 226364766f936d249e408de03821468c1bf11dda (patch) | |
tree | 3b4feabb40a87f311ae92bb973c18293d05597e8 /kernel | |
parent | 3a142ed962958d3063f648738a3384ab90017100 (diff) | |
parent | 1fb9341ac34825aa40354e74d9a2c69df7d2c304 (diff) |
Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull module fixes and a virtio block fix from Rusty Russell:
"Various minor fixes, but a slightly more complex one to fix the
per-cpu overload problem introduced recently by kvm id changes."
* tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
module: put modules in list much earlier.
module: add new state MODULE_STATE_UNFORMED.
module: prevent warning when finit_module a 0 sized file
virtio-blk: Don't free ida when disk is in use
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/debug/kdb/kdb_main.c | 2 | ||||
-rw-r--r-- | kernel/module.c | 154 |
2 files changed, 110 insertions, 46 deletions
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index 4d5f8d5612f3..8875254120b6 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c | |||
@@ -1970,6 +1970,8 @@ static int kdb_lsmod(int argc, const char **argv) | |||
1970 | 1970 | ||
1971 | kdb_printf("Module Size modstruct Used by\n"); | 1971 | kdb_printf("Module Size modstruct Used by\n"); |
1972 | list_for_each_entry(mod, kdb_modules, list) { | 1972 | list_for_each_entry(mod, kdb_modules, list) { |
1973 | if (mod->state == MODULE_STATE_UNFORMED) | ||
1974 | continue; | ||
1973 | 1975 | ||
1974 | kdb_printf("%-20s%8u 0x%p ", mod->name, | 1976 | kdb_printf("%-20s%8u 0x%p ", mod->name, |
1975 | mod->core_size, (void *)mod); | 1977 | mod->core_size, (void *)mod); |
diff --git a/kernel/module.c b/kernel/module.c index b10b048367e1..d25e359279ae 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -188,6 +188,7 @@ struct load_info { | |||
188 | ongoing or failed initialization etc. */ | 188 | ongoing or failed initialization etc. */ |
189 | static inline int strong_try_module_get(struct module *mod) | 189 | static inline int strong_try_module_get(struct module *mod) |
190 | { | 190 | { |
191 | BUG_ON(mod && mod->state == MODULE_STATE_UNFORMED); | ||
191 | if (mod && mod->state == MODULE_STATE_COMING) | 192 | if (mod && mod->state == MODULE_STATE_COMING) |
192 | return -EBUSY; | 193 | return -EBUSY; |
193 | if (try_module_get(mod)) | 194 | if (try_module_get(mod)) |
@@ -343,6 +344,9 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr, | |||
343 | #endif | 344 | #endif |
344 | }; | 345 | }; |
345 | 346 | ||
347 | if (mod->state == MODULE_STATE_UNFORMED) | ||
348 | continue; | ||
349 | |||
346 | if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data)) | 350 | if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data)) |
347 | return true; | 351 | return true; |
348 | } | 352 | } |
@@ -450,16 +454,24 @@ const struct kernel_symbol *find_symbol(const char *name, | |||
450 | EXPORT_SYMBOL_GPL(find_symbol); | 454 | EXPORT_SYMBOL_GPL(find_symbol); |
451 | 455 | ||
452 | /* Search for module by name: must hold module_mutex. */ | 456 | /* Search for module by name: must hold module_mutex. */ |
453 | struct module *find_module(const char *name) | 457 | static struct module *find_module_all(const char *name, |
458 | bool even_unformed) | ||
454 | { | 459 | { |
455 | struct module *mod; | 460 | struct module *mod; |
456 | 461 | ||
457 | list_for_each_entry(mod, &modules, list) { | 462 | list_for_each_entry(mod, &modules, list) { |
463 | if (!even_unformed && mod->state == MODULE_STATE_UNFORMED) | ||
464 | continue; | ||
458 | if (strcmp(mod->name, name) == 0) | 465 | if (strcmp(mod->name, name) == 0) |
459 | return mod; | 466 | return mod; |
460 | } | 467 | } |
461 | return NULL; | 468 | return NULL; |
462 | } | 469 | } |
470 | |||
471 | struct module *find_module(const char *name) | ||
472 | { | ||
473 | return find_module_all(name, false); | ||
474 | } | ||
463 | EXPORT_SYMBOL_GPL(find_module); | 475 | EXPORT_SYMBOL_GPL(find_module); |
464 | 476 | ||
465 | #ifdef CONFIG_SMP | 477 | #ifdef CONFIG_SMP |
@@ -525,6 +537,8 @@ bool is_module_percpu_address(unsigned long addr) | |||
525 | preempt_disable(); | 537 | preempt_disable(); |
526 | 538 | ||
527 | list_for_each_entry_rcu(mod, &modules, list) { | 539 | list_for_each_entry_rcu(mod, &modules, list) { |
540 | if (mod->state == MODULE_STATE_UNFORMED) | ||
541 | continue; | ||
528 | if (!mod->percpu_size) | 542 | if (!mod->percpu_size) |
529 | continue; | 543 | continue; |
530 | for_each_possible_cpu(cpu) { | 544 | for_each_possible_cpu(cpu) { |
@@ -1048,6 +1062,8 @@ static ssize_t show_initstate(struct module_attribute *mattr, | |||
1048 | case MODULE_STATE_GOING: | 1062 | case MODULE_STATE_GOING: |
1049 | state = "going"; | 1063 | state = "going"; |
1050 | break; | 1064 | break; |
1065 | default: | ||
1066 | BUG(); | ||
1051 | } | 1067 | } |
1052 | return sprintf(buffer, "%s\n", state); | 1068 | return sprintf(buffer, "%s\n", state); |
1053 | } | 1069 | } |
@@ -1786,6 +1802,8 @@ void set_all_modules_text_rw(void) | |||
1786 | 1802 | ||
1787 | mutex_lock(&module_mutex); | 1803 | mutex_lock(&module_mutex); |
1788 | list_for_each_entry_rcu(mod, &modules, list) { | 1804 | list_for_each_entry_rcu(mod, &modules, list) { |
1805 | if (mod->state == MODULE_STATE_UNFORMED) | ||
1806 | continue; | ||
1789 | if ((mod->module_core) && (mod->core_text_size)) { | 1807 | if ((mod->module_core) && (mod->core_text_size)) { |
1790 | set_page_attributes(mod->module_core, | 1808 | set_page_attributes(mod->module_core, |
1791 | mod->module_core + mod->core_text_size, | 1809 | mod->module_core + mod->core_text_size, |
@@ -1807,6 +1825,8 @@ void set_all_modules_text_ro(void) | |||
1807 | 1825 | ||
1808 | mutex_lock(&module_mutex); | 1826 | mutex_lock(&module_mutex); |
1809 | list_for_each_entry_rcu(mod, &modules, list) { | 1827 | list_for_each_entry_rcu(mod, &modules, list) { |
1828 | if (mod->state == MODULE_STATE_UNFORMED) | ||
1829 | continue; | ||
1810 | if ((mod->module_core) && (mod->core_text_size)) { | 1830 | if ((mod->module_core) && (mod->core_text_size)) { |
1811 | set_page_attributes(mod->module_core, | 1831 | set_page_attributes(mod->module_core, |
1812 | mod->module_core + mod->core_text_size, | 1832 | mod->module_core + mod->core_text_size, |
@@ -2527,6 +2547,13 @@ static int copy_module_from_fd(int fd, struct load_info *info) | |||
2527 | err = -EFBIG; | 2547 | err = -EFBIG; |
2528 | goto out; | 2548 | goto out; |
2529 | } | 2549 | } |
2550 | |||
2551 | /* Don't hand 0 to vmalloc, it whines. */ | ||
2552 | if (stat.size == 0) { | ||
2553 | err = -EINVAL; | ||
2554 | goto out; | ||
2555 | } | ||
2556 | |||
2530 | info->hdr = vmalloc(stat.size); | 2557 | info->hdr = vmalloc(stat.size); |
2531 | if (!info->hdr) { | 2558 | if (!info->hdr) { |
2532 | err = -ENOMEM; | 2559 | err = -ENOMEM; |
@@ -2990,8 +3017,9 @@ static bool finished_loading(const char *name) | |||
2990 | bool ret; | 3017 | bool ret; |
2991 | 3018 | ||
2992 | mutex_lock(&module_mutex); | 3019 | mutex_lock(&module_mutex); |
2993 | mod = find_module(name); | 3020 | mod = find_module_all(name, true); |
2994 | ret = !mod || mod->state != MODULE_STATE_COMING; | 3021 | ret = !mod || mod->state == MODULE_STATE_LIVE |
3022 | || mod->state == MODULE_STATE_GOING; | ||
2995 | mutex_unlock(&module_mutex); | 3023 | mutex_unlock(&module_mutex); |
2996 | 3024 | ||
2997 | return ret; | 3025 | return ret; |
@@ -3136,6 +3164,32 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
3136 | goto free_copy; | 3164 | goto free_copy; |
3137 | } | 3165 | } |
3138 | 3166 | ||
3167 | /* | ||
3168 | * We try to place it in the list now to make sure it's unique | ||
3169 | * before we dedicate too many resources. In particular, | ||
3170 | * temporary percpu memory exhaustion. | ||
3171 | */ | ||
3172 | mod->state = MODULE_STATE_UNFORMED; | ||
3173 | again: | ||
3174 | mutex_lock(&module_mutex); | ||
3175 | if ((old = find_module_all(mod->name, true)) != NULL) { | ||
3176 | if (old->state == MODULE_STATE_COMING | ||
3177 | || old->state == MODULE_STATE_UNFORMED) { | ||
3178 | /* Wait in case it fails to load. */ | ||
3179 | mutex_unlock(&module_mutex); | ||
3180 | err = wait_event_interruptible(module_wq, | ||
3181 | finished_loading(mod->name)); | ||
3182 | if (err) | ||
3183 | goto free_module; | ||
3184 | goto again; | ||
3185 | } | ||
3186 | err = -EEXIST; | ||
3187 | mutex_unlock(&module_mutex); | ||
3188 | goto free_module; | ||
3189 | } | ||
3190 | list_add_rcu(&mod->list, &modules); | ||
3191 | mutex_unlock(&module_mutex); | ||
3192 | |||
3139 | #ifdef CONFIG_MODULE_SIG | 3193 | #ifdef CONFIG_MODULE_SIG |
3140 | mod->sig_ok = info->sig_ok; | 3194 | mod->sig_ok = info->sig_ok; |
3141 | if (!mod->sig_ok) | 3195 | if (!mod->sig_ok) |
@@ -3145,7 +3199,7 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
3145 | /* Now module is in final location, initialize linked lists, etc. */ | 3199 | /* Now module is in final location, initialize linked lists, etc. */ |
3146 | err = module_unload_init(mod); | 3200 | err = module_unload_init(mod); |
3147 | if (err) | 3201 | if (err) |
3148 | goto free_module; | 3202 | goto unlink_mod; |
3149 | 3203 | ||
3150 | /* Now we've got everything in the final locations, we can | 3204 | /* Now we've got everything in the final locations, we can |
3151 | * find optional sections. */ | 3205 | * find optional sections. */ |
@@ -3180,54 +3234,33 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
3180 | goto free_arch_cleanup; | 3234 | goto free_arch_cleanup; |
3181 | } | 3235 | } |
3182 | 3236 | ||
3183 | /* Mark state as coming so strong_try_module_get() ignores us. */ | ||
3184 | mod->state = MODULE_STATE_COMING; | ||
3185 | |||
3186 | /* Now sew it into the lists so we can get lockdep and oops | ||
3187 | * info during argument parsing. No one should access us, since | ||
3188 | * strong_try_module_get() will fail. | ||
3189 | * lockdep/oops can run asynchronous, so use the RCU list insertion | ||
3190 | * function to insert in a way safe to concurrent readers. | ||
3191 | * The mutex protects against concurrent writers. | ||
3192 | */ | ||
3193 | again: | ||
3194 | mutex_lock(&module_mutex); | ||
3195 | if ((old = find_module(mod->name)) != NULL) { | ||
3196 | if (old->state == MODULE_STATE_COMING) { | ||
3197 | /* Wait in case it fails to load. */ | ||
3198 | mutex_unlock(&module_mutex); | ||
3199 | err = wait_event_interruptible(module_wq, | ||
3200 | finished_loading(mod->name)); | ||
3201 | if (err) | ||
3202 | goto free_arch_cleanup; | ||
3203 | goto again; | ||
3204 | } | ||
3205 | err = -EEXIST; | ||
3206 | goto unlock; | ||
3207 | } | ||
3208 | |||
3209 | /* This has to be done once we're sure module name is unique. */ | ||
3210 | dynamic_debug_setup(info->debug, info->num_debug); | 3237 | dynamic_debug_setup(info->debug, info->num_debug); |
3211 | 3238 | ||
3212 | /* Find duplicate symbols */ | 3239 | mutex_lock(&module_mutex); |
3240 | /* Find duplicate symbols (must be called under lock). */ | ||
3213 | err = verify_export_symbols(mod); | 3241 | err = verify_export_symbols(mod); |
3214 | if (err < 0) | 3242 | if (err < 0) |
3215 | goto ddebug; | 3243 | goto ddebug_cleanup; |
3216 | 3244 | ||
3245 | /* This relies on module_mutex for list integrity. */ | ||
3217 | module_bug_finalize(info->hdr, info->sechdrs, mod); | 3246 | module_bug_finalize(info->hdr, info->sechdrs, mod); |
3218 | list_add_rcu(&mod->list, &modules); | 3247 | |
3248 | /* Mark state as coming so strong_try_module_get() ignores us, | ||
3249 | * but kallsyms etc. can see us. */ | ||
3250 | mod->state = MODULE_STATE_COMING; | ||
3251 | |||
3219 | mutex_unlock(&module_mutex); | 3252 | mutex_unlock(&module_mutex); |
3220 | 3253 | ||
3221 | /* Module is ready to execute: parsing args may do that. */ | 3254 | /* Module is ready to execute: parsing args may do that. */ |
3222 | err = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, | 3255 | err = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, |
3223 | -32768, 32767, &ddebug_dyndbg_module_param_cb); | 3256 | -32768, 32767, &ddebug_dyndbg_module_param_cb); |
3224 | if (err < 0) | 3257 | if (err < 0) |
3225 | goto unlink; | 3258 | goto bug_cleanup; |
3226 | 3259 | ||
3227 | /* Link in to syfs. */ | 3260 | /* Link in to syfs. */ |
3228 | err = mod_sysfs_setup(mod, info, mod->kp, mod->num_kp); | 3261 | err = mod_sysfs_setup(mod, info, mod->kp, mod->num_kp); |
3229 | if (err < 0) | 3262 | if (err < 0) |
3230 | goto unlink; | 3263 | goto bug_cleanup; |
3231 | 3264 | ||
3232 | /* Get rid of temporary copy. */ | 3265 | /* Get rid of temporary copy. */ |
3233 | free_copy(info); | 3266 | free_copy(info); |
@@ -3237,16 +3270,13 @@ again: | |||
3237 | 3270 | ||
3238 | return do_init_module(mod); | 3271 | return do_init_module(mod); |
3239 | 3272 | ||
3240 | unlink: | 3273 | bug_cleanup: |
3274 | /* module_bug_cleanup needs module_mutex protection */ | ||
3241 | mutex_lock(&module_mutex); | 3275 | mutex_lock(&module_mutex); |
3242 | /* Unlink carefully: kallsyms could be walking list. */ | ||
3243 | list_del_rcu(&mod->list); | ||
3244 | module_bug_cleanup(mod); | 3276 | module_bug_cleanup(mod); |
3245 | wake_up_all(&module_wq); | ||
3246 | ddebug: | ||
3247 | dynamic_debug_remove(info->debug); | ||
3248 | unlock: | ||
3249 | mutex_unlock(&module_mutex); | 3277 | mutex_unlock(&module_mutex); |
3278 | ddebug_cleanup: | ||
3279 | dynamic_debug_remove(info->debug); | ||
3250 | synchronize_sched(); | 3280 | synchronize_sched(); |
3251 | kfree(mod->args); | 3281 | kfree(mod->args); |
3252 | free_arch_cleanup: | 3282 | free_arch_cleanup: |
@@ -3255,6 +3285,12 @@ again: | |||
3255 | free_modinfo(mod); | 3285 | free_modinfo(mod); |
3256 | free_unload: | 3286 | free_unload: |
3257 | module_unload_free(mod); | 3287 | module_unload_free(mod); |
3288 | unlink_mod: | ||
3289 | mutex_lock(&module_mutex); | ||
3290 | /* Unlink carefully: kallsyms could be walking list. */ | ||
3291 | list_del_rcu(&mod->list); | ||
3292 | wake_up_all(&module_wq); | ||
3293 | mutex_unlock(&module_mutex); | ||
3258 | free_module: | 3294 | free_module: |
3259 | module_deallocate(mod, info); | 3295 | module_deallocate(mod, info); |
3260 | free_copy: | 3296 | free_copy: |
@@ -3377,6 +3413,8 @@ const char *module_address_lookup(unsigned long addr, | |||
3377 | 3413 | ||
3378 | preempt_disable(); | 3414 | preempt_disable(); |
3379 | list_for_each_entry_rcu(mod, &modules, list) { | 3415 | list_for_each_entry_rcu(mod, &modules, list) { |
3416 | if (mod->state == MODULE_STATE_UNFORMED) | ||
3417 | continue; | ||
3380 | if (within_module_init(addr, mod) || | 3418 | if (within_module_init(addr, mod) || |
3381 | within_module_core(addr, mod)) { | 3419 | within_module_core(addr, mod)) { |
3382 | if (modname) | 3420 | if (modname) |
@@ -3400,6 +3438,8 @@ int lookup_module_symbol_name(unsigned long addr, char *symname) | |||
3400 | 3438 | ||
3401 | preempt_disable(); | 3439 | preempt_disable(); |
3402 | list_for_each_entry_rcu(mod, &modules, list) { | 3440 | list_for_each_entry_rcu(mod, &modules, list) { |
3441 | if (mod->state == MODULE_STATE_UNFORMED) | ||
3442 | continue; | ||
3403 | if (within_module_init(addr, mod) || | 3443 | if (within_module_init(addr, mod) || |
3404 | within_module_core(addr, mod)) { | 3444 | within_module_core(addr, mod)) { |
3405 | const char *sym; | 3445 | const char *sym; |
@@ -3424,6 +3464,8 @@ int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, | |||
3424 | 3464 | ||
3425 | preempt_disable(); | 3465 | preempt_disable(); |
3426 | list_for_each_entry_rcu(mod, &modules, list) { | 3466 | list_for_each_entry_rcu(mod, &modules, list) { |
3467 | if (mod->state == MODULE_STATE_UNFORMED) | ||
3468 | continue; | ||
3427 | if (within_module_init(addr, mod) || | 3469 | if (within_module_init(addr, mod) || |
3428 | within_module_core(addr, mod)) { | 3470 | within_module_core(addr, mod)) { |
3429 | const char *sym; | 3471 | const char *sym; |
@@ -3451,6 +3493,8 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, | |||
3451 | 3493 | ||
3452 | preempt_disable(); | 3494 | preempt_disable(); |
3453 | list_for_each_entry_rcu(mod, &modules, list) { | 3495 | list_for_each_entry_rcu(mod, &modules, list) { |
3496 | if (mod->state == MODULE_STATE_UNFORMED) | ||
3497 | continue; | ||
3454 | if (symnum < mod->num_symtab) { | 3498 | if (symnum < mod->num_symtab) { |
3455 | *value = mod->symtab[symnum].st_value; | 3499 | *value = mod->symtab[symnum].st_value; |
3456 | *type = mod->symtab[symnum].st_info; | 3500 | *type = mod->symtab[symnum].st_info; |
@@ -3493,9 +3537,12 @@ unsigned long module_kallsyms_lookup_name(const char *name) | |||
3493 | ret = mod_find_symname(mod, colon+1); | 3537 | ret = mod_find_symname(mod, colon+1); |
3494 | *colon = ':'; | 3538 | *colon = ':'; |
3495 | } else { | 3539 | } else { |
3496 | list_for_each_entry_rcu(mod, &modules, list) | 3540 | list_for_each_entry_rcu(mod, &modules, list) { |
3541 | if (mod->state == MODULE_STATE_UNFORMED) | ||
3542 | continue; | ||
3497 | if ((ret = mod_find_symname(mod, name)) != 0) | 3543 | if ((ret = mod_find_symname(mod, name)) != 0) |
3498 | break; | 3544 | break; |
3545 | } | ||
3499 | } | 3546 | } |
3500 | preempt_enable(); | 3547 | preempt_enable(); |
3501 | return ret; | 3548 | return ret; |
@@ -3510,6 +3557,8 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, | |||
3510 | int ret; | 3557 | int ret; |
3511 | 3558 | ||
3512 | list_for_each_entry(mod, &modules, list) { | 3559 | list_for_each_entry(mod, &modules, list) { |
3560 | if (mod->state == MODULE_STATE_UNFORMED) | ||
3561 | continue; | ||
3513 | for (i = 0; i < mod->num_symtab; i++) { | 3562 | for (i = 0; i < mod->num_symtab; i++) { |
3514 | ret = fn(data, mod->strtab + mod->symtab[i].st_name, | 3563 | ret = fn(data, mod->strtab + mod->symtab[i].st_name, |
3515 | mod, mod->symtab[i].st_value); | 3564 | mod, mod->symtab[i].st_value); |
@@ -3525,6 +3574,7 @@ static char *module_flags(struct module *mod, char *buf) | |||
3525 | { | 3574 | { |
3526 | int bx = 0; | 3575 | int bx = 0; |
3527 | 3576 | ||
3577 | BUG_ON(mod->state == MODULE_STATE_UNFORMED); | ||
3528 | if (mod->taints || | 3578 | if (mod->taints || |
3529 | mod->state == MODULE_STATE_GOING || | 3579 | mod->state == MODULE_STATE_GOING || |
3530 | mod->state == MODULE_STATE_COMING) { | 3580 | mod->state == MODULE_STATE_COMING) { |
@@ -3566,6 +3616,10 @@ static int m_show(struct seq_file *m, void *p) | |||
3566 | struct module *mod = list_entry(p, struct module, list); | 3616 | struct module *mod = list_entry(p, struct module, list); |
3567 | char buf[8]; | 3617 | char buf[8]; |
3568 | 3618 | ||
3619 | /* We always ignore unformed modules. */ | ||
3620 | if (mod->state == MODULE_STATE_UNFORMED) | ||
3621 | return 0; | ||
3622 | |||
3569 | seq_printf(m, "%s %u", | 3623 | seq_printf(m, "%s %u", |
3570 | mod->name, mod->init_size + mod->core_size); | 3624 | mod->name, mod->init_size + mod->core_size); |
3571 | print_unload_info(m, mod); | 3625 | print_unload_info(m, mod); |
@@ -3626,6 +3680,8 @@ const struct exception_table_entry *search_module_extables(unsigned long addr) | |||
3626 | 3680 | ||
3627 | preempt_disable(); | 3681 | preempt_disable(); |
3628 | list_for_each_entry_rcu(mod, &modules, list) { | 3682 | list_for_each_entry_rcu(mod, &modules, list) { |
3683 | if (mod->state == MODULE_STATE_UNFORMED) | ||
3684 | continue; | ||
3629 | if (mod->num_exentries == 0) | 3685 | if (mod->num_exentries == 0) |
3630 | continue; | 3686 | continue; |
3631 | 3687 | ||
@@ -3674,10 +3730,13 @@ struct module *__module_address(unsigned long addr) | |||
3674 | if (addr < module_addr_min || addr > module_addr_max) | 3730 | if (addr < module_addr_min || addr > module_addr_max) |
3675 | return NULL; | 3731 | return NULL; |
3676 | 3732 | ||
3677 | list_for_each_entry_rcu(mod, &modules, list) | 3733 | list_for_each_entry_rcu(mod, &modules, list) { |
3734 | if (mod->state == MODULE_STATE_UNFORMED) | ||
3735 | continue; | ||
3678 | if (within_module_core(addr, mod) | 3736 | if (within_module_core(addr, mod) |
3679 | || within_module_init(addr, mod)) | 3737 | || within_module_init(addr, mod)) |
3680 | return mod; | 3738 | return mod; |
3739 | } | ||
3681 | return NULL; | 3740 | return NULL; |
3682 | } | 3741 | } |
3683 | EXPORT_SYMBOL_GPL(__module_address); | 3742 | EXPORT_SYMBOL_GPL(__module_address); |
@@ -3730,8 +3789,11 @@ void print_modules(void) | |||
3730 | printk(KERN_DEFAULT "Modules linked in:"); | 3789 | printk(KERN_DEFAULT "Modules linked in:"); |
3731 | /* Most callers should already have preempt disabled, but make sure */ | 3790 | /* Most callers should already have preempt disabled, but make sure */ |
3732 | preempt_disable(); | 3791 | preempt_disable(); |
3733 | list_for_each_entry_rcu(mod, &modules, list) | 3792 | list_for_each_entry_rcu(mod, &modules, list) { |
3793 | if (mod->state == MODULE_STATE_UNFORMED) | ||
3794 | continue; | ||
3734 | printk(" %s%s", mod->name, module_flags(mod, buf)); | 3795 | printk(" %s%s", mod->name, module_flags(mod, buf)); |
3796 | } | ||
3735 | preempt_enable(); | 3797 | preempt_enable(); |
3736 | if (last_unloaded_module[0]) | 3798 | if (last_unloaded_module[0]) |
3737 | printk(" [last unloaded: %s]", last_unloaded_module); | 3799 | printk(" [last unloaded: %s]", last_unloaded_module); |