History

module: Use RCU in find_module_all().

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().

Sebastian Andrzej Siewior committed 1 year ago

Commit febaa651 parent c4fadf35 files · +8 −14Browse files

Showing the changes to kernel/module (2 of 5 files). Show all

Unified · Split

2 files
  1. kernel/module/kallsyms.c +1 −0
  2. kernel/module/main.c +2 −4
kernel/module/kallsyms.c+1−0
@@ -450,6 +450,7 @@ unsigned long module_kallsyms_lookup_name(const char *name) · 449 unmodified lines
450450 unsigned long ret;
451451
452452 /* Don't lock: we're in enough trouble already. */
453+ guard(rcu)();
453454 preempt_disable();
454455 ret = __module_kallsyms_lookup_name(name);
455456 preempt_enable();
kernel/module/main.c+2−4
@@ -374,16 +374,14 @@ bool find_symbol(struct find_symbol_arg *fsa) · 373 unmodified lines
374374 }
375375
376376 /*
377− * Search for module by name: must hold module_mutex (or preempt disabled
378− * for read-only access).
377+ * Search for module by name: must hold module_mutex (or RCU for read-only
378+ * access).
379379 */
380380 struct module *find_module_all(const char *name, size_t len,
381381 bool even_unformed)
382382 {
383383 struct module *mod;
384384
385− module_assert_mutex_or_preempt();
386−
387385 list_for_each_entry_rcu(mod, &modules, list,
388386 lockdep_is_held(&module_mutex)) {
389387 if (!even_unformed && mod->state == MODULE_STATE_UNFORMED)