module: remove module_text_address()
Subsystems (3)
PATCH 3/9 module: remove module_text_address()
Impact: Replace and remove risky (non-EXPORTed) API
module_text_address() returns a pointer to the module, which given locking improvements in module.c, is useless except to test for NULL:
1) If the module can't go away, use __module_text_address.
2) Otherwise, just use is_module_text_address().
Signed-off-by Rusty Russell <[email protected]>
--- drivers/mtd/nand/nand_base.c | 4 ++-- include/linux/module.h | 7 ------- kernel/extable.c | 6 +++--- kernel/module.c | 17 ++++------------- 4 files changed, 9 insertions(+), 25 deletions(-)
drivers/mtd/nand/nand_base.c +2 -2
@@ -2720,14 +2720,14 @@ int nand_scan_tail(struct mtd_info *mtd)return chip->scan_bbt (mtd); } -/* module_text_address() isn't exported, and it's mostly a pointless +/* is_module_text_address() isn't exported, and it's mostly a pointless test if this is a module _anyway_ -- they'd have to try _really_ hard to call us from in-kernel code if the core NAND support is modular. */ #ifdef MODULE #define caller_is_module () (1)#else #define caller_is_module () \ - module_text_address((unsigned long)__builtin_return_address(0)) + is_module_text_address((unsigned long)__builtin_return_address(0))#endif /**
include/linux/module.h +0 -7
@@ -358,8 +358,6 @@ static inline int module_is_live(structreturn mod->state !=MODULE_STATE_GOING ; } -/* Is this address in a module? (second is with no locks, for oops) */ -struct module *module_text_address (unsigned long addr);struct module *__module_text_address (unsigned long addr);struct module *__module_address (unsigned long addr);bool is_module_address (unsigned long addr);
@@ -488,11 +486,6 @@ extern int module_get_iter_tracepoints(s/* Given an address, look for it in the exception tables. */ static inline const struct exception_table_entry *search_module_extables (unsigned long addr) -{ -return NULL ; -} - -static inline struct module *module_text_address (unsigned long addr) {return NULL ; }
kernel/extable.c +3 -3
@@ -58,14 +58,14 @@ __notrace_funcgraph int __kernel_text_ad {if (core_kernel_text (addr))return 1 ; -return __module_text_address (addr) !=NULL ; +return is_module_text_address (addr); }int kernel_text_address (unsigned long addr) {if (core_kernel_text (addr))return 1 ; -return module_text_address (addr) !=NULL ; +return is_module_text_address (addr); }/*
@@ -81,5 +81,5 @@ int func_ptr_is_kernel_text(void *ptr) addr = (unsigned long )dereference_function_descriptor (ptr);if (core_kernel_text (addr))return 1 ; -return module_text_address (addr) !=NULL ; +return is_module_text_address (addr); }
kernel/module.c +4 -13
@@ -874,8 +874,10 @@ void symbol_put_addr(void *addr)if (core_kernel_text ((unsigned long )addr))return ; -if (!(modaddr =module_text_address ((unsigned long )addr))) -BUG (); +/* module_text_address is safe here: we're supposed to have reference +* to module from symbol_get, so it can't go away. */ + modaddr =__module_text_address ((unsigned long )addr); +BUG_ON (!modaddr);module_put (modaddr); }EXPORT_SYMBOL_GPL (symbol_put_addr);
@@ -2788,17 +2790,6 @@ struct module *__module_text_address(unsreturn mod; } -struct module *module_text_address (unsigned long addr) -{ -struct module *mod; - -preempt_disable (); - mod =__module_text_address (addr); -preempt_enable (); - -return mod; -} -/* Don't grab lock, we're oopsing. */ void print_modules (void ) {