6.1-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sebastian Andrzej Siewior <bige...@linutronix.de>

[ Upstream commit a145c848d69f9c6f32008d8319edaa133360dd74 ]

dereference_symbol_descriptor() needs to obtain the module pointer
belonging to pointer in order to resolve that pointer.
The returned mod pointer is obtained under RCU-sched/ preempt_disable()
guarantees and needs to be used within this section to ensure that the
module is not removed in the meantime.

Extend the preempt_disable() section to also cover
dereference_module_function_descriptor().

Fixes: 04b8eb7a4ccd9 ("symbol lookup: introduce 
dereference_symbol_descriptor()")
Cc: James E.J. Bottomley <james.bottom...@hansenpartnership.com>
Cc: Christophe Leroy <christophe.le...@csgroup.eu>
Cc: Helge Deller <del...@gmx.de>
Cc: Madhavan Srinivasan <ma...@linux.ibm.com>
Cc: Michael Ellerman <m...@ellerman.id.au>
Cc: Naveen N Rao <nav...@kernel.org>
Cc: Nicholas Piggin <npig...@gmail.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.w...@gmail.com>
Cc: linux-par...@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Reviewed-by: Sergey Senozhatsky <senozhat...@chromium.org>
Acked-by: Peter Zijlstra (Intel) <pet...@infradead.org>
Signed-off-by: Sebastian Andrzej Siewior <bige...@linutronix.de>
Link: https://lore.kernel.org/r/20250108090457.512198-2-bige...@linutronix.de
Signed-off-by: Petr Pavlu <petr.pa...@suse.com>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
 include/linux/kallsyms.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index 0cd33be7142ad..6d10bd2b9e0fe 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -57,10 +57,10 @@ static inline void *dereference_symbol_descriptor(void *ptr)
 
        preempt_disable();
        mod = __module_address((unsigned long)ptr);
-       preempt_enable();
 
        if (mod)
                ptr = dereference_module_function_descriptor(mod, ptr);
+       preempt_enable();
 #endif
        return ptr;
 }
-- 
2.39.5




Reply via email to