Re: [RFC PATCH 3/7] static_call: use helper to access non-exported key

From
Peter Zijlstra <peterz@infradead.org>
Date
2021-11-09 18:53:18
Also in
lkml
Reply to
Ard Biesheuvel, 2021-11-09
On Tue, Nov 09, 2021 at 05:45:45PM +0100, Ard Biesheuvel wrote:
quoted hunk ↗ jump to hunk
@@ -196,13 +190,21 @@ extern long __static_call_return0(void);
 	EXPORT_SYMBOL_GPL(STATIC_CALL_KEY(name));			\
 	EXPORT_SYMBOL_GPL(STATIC_CALL_TRAMP(name))
 
+#define EXPORT_STATIC_CALL_GETKEY_HELPER(name)				\
+	struct static_call_key *STATIC_CALL_GETKEY(name)(void) {	\
+		BUG_ON(!core_kernel_text(				\
+			(unsigned long)__builtin_return_address(0)));	\
+		return &STATIC_CALL_KEY(name);				\
+	}								\
+	EXPORT_SYMBOL_GPL(STATIC_CALL_GETKEY(name))
So if I were a nevarious module, I would look up the above symbol from
kallsyms (it is exported and easily obtainable) and then simply
read the text to discover the key address and we're in business.


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Thread (22 messages) 22 messages, 2 authors, last reply 2021-11-09
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help