Skip to content

Commit f27d8ed

Browse files
Sebastian Andrzej Siewiorpetrpavlu
authored andcommitted
module: Use RCU in __find_kallsyms_symbol_value().
module::kallsyms can be accessed under RCU assumption. Use rcu_dereference() to access module::kallsyms. Update callers. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Petr Pavlu <[email protected]>
1 parent febaa65 commit f27d8ed

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

kernel/module/kallsyms.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
407407
static unsigned long __find_kallsyms_symbol_value(struct module *mod, const char *name)
408408
{
409409
unsigned int i;
410-
struct mod_kallsyms *kallsyms = rcu_dereference_sched(mod->kallsyms);
410+
struct mod_kallsyms *kallsyms = rcu_dereference(mod->kallsyms);
411411

412412
for (i = 0; i < kallsyms->num_symtab; i++) {
413413
const Elf_Sym *sym = &kallsyms->symtab[i];
@@ -447,24 +447,15 @@ static unsigned long __module_kallsyms_lookup_name(const char *name)
447447
/* Look for this name: can be of form module:name. */
448448
unsigned long module_kallsyms_lookup_name(const char *name)
449449
{
450-
unsigned long ret;
451-
452450
/* Don't lock: we're in enough trouble already. */
453451
guard(rcu)();
454-
preempt_disable();
455-
ret = __module_kallsyms_lookup_name(name);
456-
preempt_enable();
457-
return ret;
452+
return __module_kallsyms_lookup_name(name);
458453
}
459454

460455
unsigned long find_kallsyms_symbol_value(struct module *mod, const char *name)
461456
{
462-
unsigned long ret;
463-
464-
preempt_disable();
465-
ret = __find_kallsyms_symbol_value(mod, name);
466-
preempt_enable();
467-
return ret;
457+
guard(rcu)();
458+
return __find_kallsyms_symbol_value(mod, name);
468459
}
469460

470461
int module_kallsyms_on_each_symbol(const char *modname,

0 commit comments

Comments
 (0)