]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
module: Use RCU in all users of __module_text_address().
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Wed, 8 Jan 2025 09:04:44 +0000 (10:04 +0100)
committerPetr Pavlu <petr.pavlu@suse.com>
Mon, 10 Mar 2025 10:54:45 +0000 (11:54 +0100)
__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>
kernel/module/main.c

index 8a8b499730d865e8ac5e684207dd5cb882ac4018..81ecb9d3a93530a59f71bbbd987d0eef1245de9a 100644 (file)
@@ -823,13 +823,12 @@ void symbol_put_addr(void *addr)
 
        /*
         * Even though we hold a reference on the module; we still need to
-        * disable preemption in order to safely traverse the data structure.
+        * RCU read section in order to safely traverse the data structure.
         */
-       preempt_disable();
+       guard(rcu)();
        modaddr = __module_text_address(a);
        BUG_ON(!modaddr);
        module_put(modaddr);
-       preempt_enable();
 }
 EXPORT_SYMBOL_GPL(symbol_put_addr);
 
@@ -3776,20 +3775,15 @@ lookup:
  */
 bool is_module_text_address(unsigned long addr)
 {
-       bool ret;
-
-       preempt_disable();
-       ret = __module_text_address(addr) != NULL;
-       preempt_enable();
-
-       return ret;
+       guard(rcu)();
+       return __module_text_address(addr) != NULL;
 }
 
 /**
  * __module_text_address() - get the module whose code contains an address.
  * @addr: the address.
  *
- * Must be called with preempt disabled or module mutex held so that
+ * Must be called within RCU read section or module mutex held so that
  * module doesn't get freed during this.
  */
 struct module *__module_text_address(unsigned long addr)