live-patching.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ftrace/x86: Add a comment to why we take text_mutex in ftrace_arch_code_modify_prepare()
@ 2019-06-28  1:18 Steven Rostedt
  2019-06-28  1:21 ` Josh Poimboeuf
  2019-06-28 10:54 ` Petr Mladek
  0 siblings, 2 replies; 4+ messages in thread
From: Steven Rostedt @ 2019-06-28  1:18 UTC (permalink / raw)
  To: LKML
  Cc: Josh Poimboeuf, Thomas Gleixner, Petr Mladek, Miroslav Benes,
	Jessica Yu, Jiri Kosina, Joe Lawrence, live-patching,
	Johannes Erdfelt, Ingo Molnar, mhiramat, torvalds


From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

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.

Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 arch/x86/kernel/ftrace.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 33786044d5ac..d7e93b2783fd 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -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();
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-28 10:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-28  1:18 [PATCH] ftrace/x86: Add a comment to why we take text_mutex in ftrace_arch_code_modify_prepare() Steven Rostedt
2019-06-28  1:21 ` Josh Poimboeuf
2019-06-28  1:37   ` Steven Rostedt
2019-06-28 10:54 ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).