The modules list and module::kallsyms can be accessed under RCU assumption. Remove module_assert_mutex_or_preempt() from find_module_all() so it can be used under RCU protection without warnings. Update its callers to use RCU protection instead of preempt_disable().
Showing the changes to kernel/module (2 of 5 files). Show all
Unified · Split
| @@ -450,6 +450,7 @@ unsigned long module_kallsyms_lookup_name(const char *name) · 449 unmodified lines | |||
| 450 | unsigned long ret; | 450 | unsigned long ret; |
| 451 | 451 | ||
| 452 | /* Don't lock: we're in enough trouble already. */ | 452 | /* Don't lock: we're in enough trouble already. */ |
| 453 | guard(rcu)(); | ||
| 453 | preempt_disable(); | 454 | preempt_disable(); |
| 454 | ret = __module_kallsyms_lookup_name(name); | 455 | ret = __module_kallsyms_lookup_name(name); |
| 455 | preempt_enable(); | 456 | preempt_enable(); |
| @@ -374,16 +374,14 @@ bool find_symbol(struct find_symbol_arg *fsa) · 373 unmodified lines | |||
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | /* | 376 | /* |
| 377 | * Search for module by name: must hold module_mutex (or preempt disabled | 377 | * Search for module by name: must hold module_mutex (or RCU for read-only |
| 378 | * for read-only access). | 378 | * access). |
| 379 | */ | 379 | */ |
| 380 | struct module *find_module_all(const char *name, size_t len, | 380 | struct module *find_module_all(const char *name, size_t len, |
| 381 | bool even_unformed) | 381 | bool even_unformed) |
| 382 | { | 382 | { |
| 383 | struct module *mod; | 383 | struct module *mod; |
| 384 | 384 | ||
| 385 | module_assert_mutex_or_preempt(); | ||
| 386 | |||
| 387 | list_for_each_entry_rcu(mod, &modules, list, | 385 | list_for_each_entry_rcu(mod, &modules, list, |
| 388 | lockdep_is_held(&module_mutex)) { | 386 | lockdep_is_held(&module_mutex)) { |
| 389 | if (!even_unformed && mod->state == MODULE_STATE_UNFORMED) | 387 | if (!even_unformed && mod->state == MODULE_STATE_UNFORMED) |