From: Jessica Yu <jeyu@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write
Date: Mon, 14 Oct 2019 14:31:21 +0200 [thread overview]
Message-ID: <20191014123120.GB6525@linux-8ccs> (raw)
In-Reply-To: <20191010085846.2e7cc625@gandalf.local.home>
+++ Steven Rostedt [10/10/19 08:58 -0400]:
>On Wed, 9 Oct 2019 22:36:38 -0400
>Steven Rostedt <rostedt@goodmis.org> wrote:
>
>> --- a/kernel/module.c
>> +++ b/kernel/module.c
>> @@ -2029,6 +2029,37 @@ static void module_enable_nx(const struct module *mod)
>> frob_writable_data(&mod->init_layout, set_memory_nx);
>> }
>>
>
>Also, if you are worried about these being used anywhere else, we can
>add:
>
>> +void set_module_text_rw(const struct module *mod)
>> +{
>> + if (!rodata_enabled)
>> + return;
>> +
>> + mutex_lock(&module_mutex);
>> + if (mod->state == MODULE_STATE_UNFORMED)
>
> if (mod->state == MODULE_STATE_UNFORMED ||
> mod->state == MODULE_STATE_LIVE)
>
>As this will keep it from being used on modules that are executing.
Yeah, that'd be good. Aside from the big ftrace_module_init/enable
debate, I'm fine with this patch itself (with the change above), feel
free to include my Ack in case you want to include it with the rest of
the ftrace text_poke stuff.
Acked-by: Jessica Yu <jeyu@kernel.org>
Thanks,
Jessica
>> + goto out;
>> +
>> + frob_text(&mod->core_layout, set_memory_rw);
>> + frob_text(&mod->init_layout, set_memory_rw);
>> +out:
>> + mutex_unlock(&module_mutex);
>> +}
>> +
>> +void set_module_text_ro(const struct module *mod)
>> +{
>> + if (!rodata_enabled)
>> + return;
>> +
>> + mutex_lock(&module_mutex);
>> + if (mod->state == MODULE_STATE_UNFORMED ||
>> + mod->state == MODULE_STATE_GOING)
>> + goto out;
>> +
>> + frob_text(&mod->core_layout, set_memory_ro);
>> + frob_text(&mod->init_layout, set_memory_ro);
>> +out:
>> + mutex_unlock(&module_mutex);
>> +}
>> +
prev parent reply other threads:[~2019-10-14 12:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-10 2:36 [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write Steven Rostedt
2019-10-10 7:31 ` Peter Zijlstra
2019-10-10 9:26 ` Peter Zijlstra
2019-10-10 9:33 ` Peter Zijlstra
2019-10-10 9:36 ` Peter Zijlstra
2019-10-10 12:29 ` Peter Zijlstra
2019-10-10 14:55 ` Steven Rostedt
2019-10-10 15:03 ` Steven Rostedt
2019-10-10 16:59 ` Steven Rostedt
2019-10-10 17:01 ` Peter Zijlstra
2019-10-10 17:20 ` Steven Rostedt
2019-10-11 11:09 ` Peter Zijlstra
2019-10-10 12:50 ` Steven Rostedt
2019-10-10 14:11 ` Peter Zijlstra
2019-10-10 12:58 ` Steven Rostedt
2019-10-14 12:31 ` Jessica Yu [this message]
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=20191014123120.GB6525@linux-8ccs \
--to=jeyu@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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