提交 39611265 编写于 作者: S Steven Rostedt (VMware)

ftrace/x86: Add a comment to why we take text_mutex in ftrace_arch_code_modify_prepare()

Taking the text_mutex in ftrace_arch_code_modify_prepare() is to fix a
race against module loading and live kernel patching that might try to
change the text permissions while ftrace has it as read/write. This
really needs to be documented in the code. Add a comment that does such.

Link: http://lkml.kernel.org/r/20190627211819.5a591f52@gandalf.local.homeSuggested-by: NJosh Poimboeuf <jpoimboe@redhat.com>
Reviewed-by: NJosh Poimboeuf <jpoimboe@redhat.com>
Reviewed-by: NPetr Mladek <pmladek@suse.com>
Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
上级 d5b844a2
...@@ -36,6 +36,11 @@ ...@@ -36,6 +36,11 @@
int ftrace_arch_code_modify_prepare(void) int ftrace_arch_code_modify_prepare(void)
{ {
/*
* Need to grab text_mutex to prevent a race from module loading
* and live kernel patching from changing the text permissions while
* ftrace has it set to "read/write".
*/
mutex_lock(&text_mutex); mutex_lock(&text_mutex);
set_kernel_text_rw(); set_kernel_text_rw();
set_all_modules_text_rw(); set_all_modules_text_rw();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册