]> git.baikalelectronics.ru Git - kernel.git/commit
ftrace: Fix the race between ftrace and insmod
authorQiu Peiyang <peiyangx.qiu@intel.com>
Fri, 25 Dec 2015 06:46:00 +0000 (14:46 +0800)
committerSteven Rostedt <rostedt@goodmis.org>
Thu, 7 Jan 2016 20:56:21 +0000 (15:56 -0500)
commit281afaa7d7ea00decaa23f2d990c4afd77f12ee5
tree9b75d4ecfe3d1d1b20d73f21baab2bf0b0969b70
parent7990eb104e44b2cd5b9718dd84e43a9783a0b927
ftrace: Fix the race between ftrace and insmod

We hit ftrace_bug report when booting Android on a 64bit ATOM SOC chip.
Basically, there is a race between insmod and ftrace_run_update_code.

After load_module=>ftrace_module_init, another thread jumps in to call
ftrace_run_update_code=>ftrace_arch_code_modify_prepare
                        =>set_all_modules_text_rw, to change all modules
as RW. Since the new module is at MODULE_STATE_UNFORMED, the text attribute
is not changed. Then, the 2nd thread goes ahead to change codes.
However, load_module continues to call complete_formation=>set_section_ro_nx,
then 2nd thread would fail when probing the module's TEXT.

The patch fixes it by using notifier to delay the enabling of ftrace
records to the time when module is at state MODULE_STATE_COMING.

Link: http://lkml.kernel.org/r/567CE628.3000609@intel.com
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
Signed-off-by: Zhang Yanmin <yanmin.zhang@intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/ftrace.c