From: Steven Rostedt <rostedt@goodmis.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Jessica Yu <jeyu@kernel.org>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write
Date: Thu, 10 Oct 2019 12:59:15 -0400 [thread overview]
Message-ID: <20191010125915.34a2cfdf@gandalf.local.home> (raw)
In-Reply-To: <20191010105515.5eba7f31@gandalf.local.home>
On Thu, 10 Oct 2019 10:55:15 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
I'll try to add more detail (mapping to functions)
>
> OK, so basically this moves the enabling of function tracing from
> within the ftrace_module_enable() code without releasing the
> ftrace_lock mutex.
>
> But we have an issue with the state of the module here, as it is still
> set as MODULE_STATE_UNFORMED. Let's look at what happens if we have:
>
>
> CPU0 CPU1
> ---- ----
> echo function > current_tracer
Just need to know that the above will now have all loaded modules have
their functions being traced. That is ftrace_startup > 0.
> modprobe foo
> enable foo functions to be traced
> (foo function records not disabled)
In your code, we have here:
load_module()
foo->state == UNFORMED
ftrace_module_init()
ftrace_process_locs()
mutex_lock(ftrace_lock);
__ftrace_replace_code(rec, 1)
/* Enabling foo's functions */
mutex_unlock(ftrace_lock);
> echo nop > current_tracer
>
> disable all functions being
> traced including foo functions
ftrace_shutdown()
ftrace_run_update_code()
ftrace_arch_code_modify_prepare()
[ on arm and nds32 ]
>
> arch calls set_all_modules_text_rw()
> [skips UNFORMED modules, which foo still is ]
>
> set foo's text to read-only
> foo's state to COMING
complete_formation()
module_enable_ro()
>
> tries to disable foo's functions
> foo's text is read-only
arch_ftrace_update_code()
ftrace_modify_all_code()
[ Includes foo's functions ]
>
> BUG trying to write to ro text!!!
Hope that makes more sense.
-- Steve
>
>
> Like I said, this is very subtle. It may no longer be a bug on x86
> with your patches, but it will bug on ARM or anything else that still
> uses set_all_modules_text_rw() in the ftrace prepare code.
next prev parent reply other threads:[~2019-10-10 16:59 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 [this message]
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
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=20191010125915.34a2cfdf@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=jeyu@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.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 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.