* [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
* Re: [PATCH] ftrace/x86: Add a comment to why we take text_mutex in ftrace_arch_code_modify_prepare()
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
1 sibling, 1 reply; 4+ messages in thread
From: Josh Poimboeuf @ 2019-06-28 1:21 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Thomas Gleixner, Petr Mladek, Miroslav Benes, Jessica Yu,
Jiri Kosina, Joe Lawrence, live-patching, Johannes Erdfelt,
Ingo Molnar, mhiramat, torvalds
On Thu, Jun 27, 2019 at 09:18:19PM -0400, Steven Rostedt wrote:
>
> 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
>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
--
Josh
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ftrace/x86: Add a comment to why we take text_mutex in ftrace_arch_code_modify_prepare()
2019-06-28 1:21 ` Josh Poimboeuf
@ 2019-06-28 1:37 ` Steven Rostedt
0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2019-06-28 1:37 UTC (permalink / raw)
To: Josh Poimboeuf
Cc: LKML, Thomas Gleixner, Petr Mladek, Miroslav Benes, Jessica Yu,
Jiri Kosina, Joe Lawrence, live-patching, Johannes Erdfelt,
Ingo Molnar, mhiramat, torvalds
On Thu, 27 Jun 2019 20:21:09 -0500
Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> On Thu, Jun 27, 2019 at 09:18:19PM -0400, Steven Rostedt wrote:
> >
> > 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>
>
> Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
>
Thanks!
-- Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ftrace/x86: Add a comment to why we take text_mutex in ftrace_arch_code_modify_prepare()
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 10:54 ` Petr Mladek
1 sibling, 0 replies; 4+ messages in thread
From: Petr Mladek @ 2019-06-28 10:54 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Johannes Erdfelt, Jessica Yu, Jiri Kosina, mhiramat,
Ingo Molnar, Thomas Gleixner, torvalds, Joe Lawrence,
Josh Poimboeuf, Miroslav Benes, live-patching
On Thu 2019-06-27 21:18:19, Steven Rostedt wrote:
>
> 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>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Best Regards,
Petr
^ permalink raw reply [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).