From: Takao Indoh <indou.takao@jp.fujitsu.com>
To: rostedt@goodmis.org, masami.hiramatsu.pt@hitachi.com
Cc: fweisbec@gmail.com, mingo@redhat.com, ananth@in.ibm.com,
anil.s.keshavamurthy@intel.com, davem@davemloft.net,
linux-kernel@vger.kernel.org, rusty@rustcorp.com.au
Subject: Re: ftrace/kprobes: Warning when insmod two modules
Date: Tue, 25 Mar 2014 14:54:26 +0900 [thread overview]
Message-ID: <53311A12.50506@jp.fujitsu.com> (raw)
In-Reply-To: <20140324105939.7f823b81@gandalf.local.home>
(2014/03/24 23:59), Steven Rostedt wrote:
> On Mon, 24 Mar 2014 20:26:05 +0900
> Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> wrote:
>
>
>> Thank you for reporting with this pretty backtrace :)
>> Steven, I think this is not the kprobe bug but ftrace (and perhaps, module).
>
> Looks to be more of a module issue than a ftrace issue.
>
>>
>> If the ftrace can set loading module text read only before the module subsystem
>> expected, I think it should be protected by the module subsystem itself
>> (e.g. set_all_modules_text_ro(rw) skips the modules which is MODULE_STATE_COMING)
>>
>
> Does this patch fix it?
Yep, I tested using my reproducer and confirmed that this patch fixed
this issue, thanks!
Thanks,
Takao Indoh
>
> In-review-off-by: Steven Rostedt <rostedt@goodmis.org>
>
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 5a50539..a1acabf 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -207,10 +207,11 @@ struct module_use {
> };
>
> enum module_state {
> - MODULE_STATE_LIVE, /* Normal state. */
> - MODULE_STATE_COMING, /* Full formed, running module_init. */
> - MODULE_STATE_GOING, /* Going away. */
> - MODULE_STATE_UNFORMED, /* Still setting it up. */
> + MODULE_STATE_LIVE, /* Normal state. */
> + MODULE_STATE_COMING, /* Full formed, running module_init. */
> + MODULE_STATE_COMING_FINAL, /* Ready to be changed to read only. */
> + MODULE_STATE_GOING, /* Going away. */
> + MODULE_STATE_UNFORMED, /* Still setting it up. */
> };
>
> /**
> diff --git a/kernel/module.c b/kernel/module.c
> index d24fcf2..0905bed 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -1805,7 +1805,8 @@ void set_all_modules_text_ro(void)
>
> mutex_lock(&module_mutex);
> list_for_each_entry_rcu(mod, &modules, list) {
> - if (mod->state == MODULE_STATE_UNFORMED)
> + if (mod->state == MODULE_STATE_UNFORMED ||
> + mod->state == MODULE_STATE_COMING)
> continue;
> if ((mod->module_core) && (mod->core_text_size)) {
> set_page_attributes(mod->module_core,
> @@ -3020,6 +3021,13 @@ static int do_init_module(struct module *mod)
> blocking_notifier_call_chain(&module_notify_list,
> MODULE_STATE_COMING, mod);
>
> + /*
> + * This module must not be changed by set_all_modules_text_ro()
> + * until we get here. Otherwise notifiers that change text
> + * (like ftrace does) will break.
> + */
> + mod->state = MODULE_STATE_COMING_FINAL;
> +
> /* Set RO and NX regions for core */
> set_section_ro_nx(mod->module_core,
> mod->core_text_size,
>
>
>
--
印藤隆夫(INDOH Takao)
E-Mail : indou.takao@jp.fujitsu.com
TEL : 7551-4832(055-924-7241)
富士通(株) PFソ事本)Linux開発統括部 開発部
next prev parent reply other threads:[~2014-03-25 5:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-24 5:10 ftrace/kprobes: Warning when insmod two modules Takao Indoh
2014-03-24 11:26 ` Masami Hiramatsu
2014-03-24 14:27 ` Steven Rostedt
2014-03-24 14:59 ` Steven Rostedt
2014-03-25 5:54 ` Takao Indoh [this message]
2014-04-22 3:51 ` Rusty Russell
2014-04-22 5:29 ` Takao Indoh
2014-04-22 7:28 ` Masami Hiramatsu
2014-04-22 8:35 ` Takao Indoh
2014-04-23 1:26 ` Masami Hiramatsu
2014-04-23 1:56 ` Steven Rostedt
2014-04-23 2:37 ` Masami Hiramatsu
2014-04-24 6:58 ` Takao Indoh
2014-04-24 12:49 ` Steven Rostedt
2014-04-22 13:41 ` Steven Rostedt
2014-04-24 7:38 ` Rusty Russell
2014-04-24 12:21 ` Steven Rostedt
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=53311A12.50506@jp.fujitsu.com \
--to=indou.takao@jp.fujitsu.com \
--cc=ananth@in.ibm.com \
--cc=anil.s.keshavamurthy@intel.com \
--cc=davem@davemloft.net \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.