aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2008-08-14 22:47:19 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-14 04:35:12 -0400
commitfed1939c64d2288938fdc1c367d49082da65e195 (patch)
treea4592352d28efcfe82379c71d061b9127e49a115 /kernel/module.c
parent28614889bcb2558a47d02d52394b7fd9795a9547 (diff)
ftrace: remove old pointers to mcount
When a mcount pointer is recorded into a table, it is used to add or remove calls to mcount (replacing them with nops). If the code is removed via removing a module, the pointers still exist. At modifying the code a check is always made to make sure the code being replaced is the code expected. In-other-words, the code being replaced is compared to what it is expected to be before being replaced. There is a very small chance that the code being replaced just happens to look like code that calls mcount (very small since the call to mcount is relative). To remove this chance, this patch adds ftrace_release to allow module unloading to remove the pointers to mcount within the module. Another change for init calls is made to not trace calls marked with __init. The tracing can not be started until after init is done anyway. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/module.c')
-rw-r--r--kernel/module.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/kernel/module.c b/kernel/module.c
index d753fd9d83ec..7576c2d9462f 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1431,6 +1431,9 @@ static void free_module(struct module *mod)
1431 /* Module unload stuff */ 1431 /* Module unload stuff */
1432 module_unload_free(mod); 1432 module_unload_free(mod);
1433 1433
1434 /* release any pointers to mcount in this module */
1435 ftrace_release(mod->module_core, mod->core_size);
1436
1434 /* This may be NULL, but that's OK */ 1437 /* This may be NULL, but that's OK */
1435 module_free(mod, mod->module_init); 1438 module_free(mod, mod->module_init);
1436 kfree(mod->args); 1439 kfree(mod->args);
@@ -1839,6 +1842,7 @@ static noinline struct module *load_module(void __user *umod,
1839 struct module *mod; 1842 struct module *mod;
1840 long err = 0; 1843 long err = 0;
1841 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ 1844 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
1845 void *mseg;
1842 struct exception_table_entry *extable; 1846 struct exception_table_entry *extable;
1843 mm_segment_t old_fs; 1847 mm_segment_t old_fs;
1844 1848
@@ -2190,10 +2194,9 @@ static noinline struct module *load_module(void __user *umod,
2190#endif 2194#endif
2191 } 2195 }
2192 2196
2193 if (mcountindex) { 2197 /* sechdrs[0].sh_size is always zero */
2194 void *mseg = (void *)sechdrs[mcountindex].sh_addr; 2198 mseg = (void *)sechdrs[mcountindex].sh_addr;
2195 ftrace_init_module(mseg, mseg + sechdrs[mcountindex].sh_size); 2199 ftrace_init_module(mseg, mseg + sechdrs[mcountindex].sh_size);
2196 }
2197 2200
2198 err = module_finalize(hdr, sechdrs, mod); 2201 err = module_finalize(hdr, sechdrs, mod);
2199 if (err < 0) 2202 if (err < 0)
@@ -2264,6 +2267,7 @@ static noinline struct module *load_module(void __user *umod,
2264 cleanup: 2267 cleanup:
2265 kobject_del(&mod->mkobj.kobj); 2268 kobject_del(&mod->mkobj.kobj);
2266 kobject_put(&mod->mkobj.kobj); 2269 kobject_put(&mod->mkobj.kobj);
2270 ftrace_release(mod->module_core, mod->core_size);
2267 free_unload: 2271 free_unload:
2268 module_unload_free(mod); 2272 module_unload_free(mod);
2269 module_free(mod, mod->module_init); 2273 module_free(mod, mod->module_init);