aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/module.h
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2009-01-06 17:41:49 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-06 18:59:20 -0500
commita06f6211ef9b1785922f9d0e8766d63ac4e66de1 (patch)
tree4ceac7a7eda00cad3b3f02876e75c1c7af41ce23 /include/linux/module.h
parent12da3b888b2035bb0f106122f1cc1b6d357fad53 (diff)
module: add within_module_core() and within_module_init()
This series of patches allows kprobes to probe module's __init and __exit functions. This means, you can probe driver initialization and terminating. Currently, kprobes can't probe __init function because these functions are freed after module initialization. And it also can't probe module __exit functions because kprobe increments reference count of target module and user can't unload it. this means __exit functions never be called unless removing probes from the module. To solve both cases, this series of patches introduces GONE flag and sets it when the target code is freed(for this purpose, kprobes hooks MODULE_STATE_* events). This also removes refcount incrementing for allowing user to unload target module. Users can check which probes are GONE by debugfs interface. For taking timing of freeing module's .init text, these also include a patch which adds module's notifier of MODULE_STATE_LIVE event. This patch: Add within_module_core() and within_module_init() for checking whether an address is in the module .init.text section or .text section, and replace within() local inline functions in kernel/module.c with them. kprobes uses these functions to check where the kprobe is inserted. Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Acked-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/module.h')
-rw-r--r--include/linux/module.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/module.h b/include/linux/module.h
index 03cb93d1865a..4f7ea12463d3 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -365,6 +365,18 @@ struct module *module_text_address(unsigned long addr);
365struct module *__module_text_address(unsigned long addr); 365struct module *__module_text_address(unsigned long addr);
366int is_module_address(unsigned long addr); 366int is_module_address(unsigned long addr);
367 367
368static inline int within_module_core(unsigned long addr, struct module *mod)
369{
370 return (unsigned long)mod->module_core <= addr &&
371 addr < (unsigned long)mod->module_core + mod->core_size;
372}
373
374static inline int within_module_init(unsigned long addr, struct module *mod)
375{
376 return (unsigned long)mod->module_init <= addr &&
377 addr < (unsigned long)mod->module_init + mod->init_size;
378}
379
368/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if 380/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
369 symnum out of range. */ 381 symnum out of range. */
370int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, 382int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,