ftrace/x86: Add a comment to why we take text_mutex in ftrace_arch_code_modify_prepare()
Subsystems (3)
Steven Rostedt
maintainerPATCH 1/1 ftrace/x86: Add a comment to why we take text_mutex in ftrace_arch_code_modify_prepare()
From: "Steven Rostedt (VMware)" <[email protected]>
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.
--- arch/x86/kernel/ftrace.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/x86/kernel/ftrace.c +5 -0
@@ -36,6 +36,11 @@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);set_kernel_text_rw ();set_all_modules_text_rw ();
Signature · 1 line
2.20.1
Quoted 33 lines · Steven Rostedt
From: "Steven Rostedt (VMware)" <[email protected]>
Taking the
text_mutexinftrace_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.Suggested-by Josh Poimboeuf <[email protected]>Signed-off-by Steven Rostedt (VMware) <[email protected]>--- arch/x86/kernel/ftrace.c | 5 +++++ 1 file changed, 5 insertions(+)arch/x86/kernel/ftrace.c +5
-0@@ -36,6 +36,11 @@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);set_kernel_text_rw ();set_all_modules_text_rw ();Signature · 1 line
2.20.1
Signature · 1 line
Josh
Steven Rostedt
maintainerQuoted 9 lines · On Thu, 27 Jun 2019 20:21:09 -0500 Josh Poimboeuf <[email protected]> wrote:
Quoted 8 lines · Steven Rostedt
From: "Steven Rostedt (VMware)" <[email protected]>
Taking the
text_mutexinftrace_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.
Quoted 7 lines
Quoted 2 lines
Suggested-by Josh Poimboeuf <[email protected]>Signed-off-by Steven Rostedt (VMware) <[email protected]>Reviewed-by Josh Poimboeuf <[email protected]>
Thanks!
-- Steve
Quoted 10 lines · Steven Rostedt
From: "Steven Rostedt (VMware)" <[email protected]>
Taking the
text_mutexinftrace_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.Suggested-by Josh Poimboeuf <[email protected]>Signed-off-by Steven Rostedt (VMware) <[email protected]>
Best Regards,
Petr