Skip to content

Commit d593e0c

Browse files
Sebastian Andrzej Siewiorpetrpavlu
authored andcommitted
module: Use RCU in all users of __module_text_address().
__module_text_address() can be invoked within a RCU section, there is no requirement to have preemption disabled. Replace the preempt_disable() section around __module_text_address() with RCU. 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-16-bigeasy@linutronix.de Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
1 parent 6593a2c commit d593e0c

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

kernel/module/main.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -823,13 +823,12 @@ void symbol_put_addr(void *addr)
823823

824824
/*
825825
* Even though we hold a reference on the module; we still need to
826-
* disable preemption in order to safely traverse the data structure.
826+
* RCU read section in order to safely traverse the data structure.
827827
*/
828-
preempt_disable();
828+
guard(rcu)();
829829
modaddr = __module_text_address(a);
830830
BUG_ON(!modaddr);
831831
module_put(modaddr);
832-
preempt_enable();
833832
}
834833
EXPORT_SYMBOL_GPL(symbol_put_addr);
835834

@@ -3776,20 +3775,15 @@ struct module *__module_address(unsigned long addr)
37763775
*/
37773776
bool is_module_text_address(unsigned long addr)
37783777
{
3779-
bool ret;
3780-
3781-
preempt_disable();
3782-
ret = __module_text_address(addr) != NULL;
3783-
preempt_enable();
3784-
3785-
return ret;
3778+
guard(rcu)();
3779+
return __module_text_address(addr) != NULL;
37863780
}
37873781

37883782
/**
37893783
* __module_text_address() - get the module whose code contains an address.
37903784
* @addr: the address.
37913785
*
3792-
* Must be called with preempt disabled or module mutex held so that
3786+
* Must be called within RCU read section or module mutex held so that
37933787
* module doesn't get freed during this.
37943788
*/
37953789
struct module *__module_text_address(unsigned long addr)

0 commit comments

Comments
 (0)