From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Petr Mladek <pmladek@suse.com>, Miroslav Benes <mbenes@suse.cz>,
Jessica Yu <jeyu@kernel.org>, Jiri Kosina <jikos@kernel.org>,
Joe Lawrence <joe.lawrence@redhat.com>,
live-patching@vger.kernel.org,
Johannes Erdfelt <johannes@erdfelt.com>,
Ingo Molnar <mingo@kernel.org>,
mhiramat@kernel.org, torvalds@linux-foundation.org
Subject: Re: [PATCH] ftrace/x86: Add a comment to why we take text_mutex in ftrace_arch_code_modify_prepare()
Date: Thu, 27 Jun 2019 20:21:09 -0500 [thread overview]
Message-ID: <20190628012109.p7a2whpsnad5vjz7@treble> (raw)
In-Reply-To: <20190627211819.5a591f52@gandalf.local.home>
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
next prev parent reply other threads:[~2019-06-28 1:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2019-06-28 1:37 ` Steven Rostedt
2019-06-28 10:54 ` Petr Mladek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190628012109.p7a2whpsnad5vjz7@treble \
--to=jpoimboe@redhat.com \
--cc=jeyu@kernel.org \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=johannes@erdfelt.com \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox