Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

module: Use RCU in find_kallsyms_symbol().

The modules list and module::kallsyms can be accessed under RCU
assumption.

Use rcu_dereference() to reference the kallsyms pointer in
find_kallsyms_symbol(). Use a RCU section instead of preempt_disable in
callers of find_kallsyms_symbol(). Keep the preempt-disable in
module_address_lookup() due to __module_address().

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250108090457.512198-5-bigeasy@linutronix.de
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>

authored by

Sebastian Andrzej Siewior and committed by
Petr Pavlu
f0136923 039de468

+3 -4
+3 -4
kernel/module/kallsyms.c
··· 257 257 { 258 258 unsigned int i, best = 0; 259 259 unsigned long nextval, bestval; 260 - struct mod_kallsyms *kallsyms = rcu_dereference_sched(mod->kallsyms); 260 + struct mod_kallsyms *kallsyms = rcu_dereference(mod->kallsyms); 261 261 struct module_memory *mod_mem; 262 262 263 263 /* At worse, next value is at end of module */ ··· 329 329 int ret = 0; 330 330 struct module *mod; 331 331 332 + guard(rcu)(); 332 333 preempt_disable(); 333 334 mod = __module_address(addr); 334 335 if (mod) { ··· 357 356 { 358 357 struct module *mod; 359 358 360 - preempt_disable(); 359 + guard(rcu)(); 361 360 list_for_each_entry_rcu(mod, &modules, list) { 362 361 if (mod->state == MODULE_STATE_UNFORMED) 363 362 continue; ··· 369 368 goto out; 370 369 371 370 strscpy(symname, sym, KSYM_NAME_LEN); 372 - preempt_enable(); 373 371 return 0; 374 372 } 375 373 } 376 374 out: 377 - preempt_enable(); 378 375 return -ERANGE; 379 376 } 380 377