Subject: [PATCH 24/28] jump_label: Use RCU in all users of __module_text_address().
From: Sebastian Andrzej Siewior <[email-masked]>
Date: Wed, 8 Jan 2025 10:04:53 +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.

Cc: Ard Biesheuvel <[email-masked]>
Cc: Jason Baron <[email-masked]>
Cc: Josh Poimboeuf <[email-masked]>
Cc: Peter Zijlstra <[email-masked]>
Cc: Steven Rostedt <[email-masked]>
Acked-by: Peter Zijlstra (Intel) <[email-masked]>
Link: https://lore.kernel.org/r/[email-masked]
Signed-off-by: Sebastian Andrzej Siewior <[email-masked]>
---
 kernel/jump_label.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -653,13 +653,12 @@ static int __jump_label_mod_text_reserve
 	struct module *mod;
 	int ret;
 
-	preempt_disable();
-	mod = __module_text_address((unsigned long)start);
-	WARN_ON_ONCE(__module_text_address((unsigned long)end) != mod);
-	if (!try_module_get(mod))
-		mod = NULL;
-	preempt_enable();
-
+	scoped_guard(rcu) {
+		mod = __module_text_address((unsigned long)start);
+		WARN_ON_ONCE(__module_text_address((unsigned long)end) != mod);
+		if (!try_module_get(mod))
+			mod = NULL;
+	}
 	if (!mod)
 		return 0;