Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-14 Thread Jessica Yu
+++ Steven Rostedt [10/10/19 08:58 -0400]: On Wed, 9 Oct 2019 22:36:38 -0400 Steven Rostedt 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,

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-11 Thread Peter Zijlstra
On Thu, Oct 10, 2019 at 01:20:13PM -0400, Steven Rostedt wrote: > Hmm, I'm lost at what the below is trying to do with respect to the > above. The below is an alternative approach for the module load issue. It accepts we patch 'late' and then uses text_poke_bp(). It works. We can then look at mov

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-10 Thread Steven Rostedt
On Thu, 10 Oct 2019 19:01:11 +0200 Peter Zijlstra wrote: > On Thu, Oct 10, 2019 at 10:55:15AM -0400, Steven Rostedt wrote: > > > OK, so basically this moves the enabling of function tracing from > > within the ftrace_module_enable() code without releasing the > > ftrace_lock mutex. > > > > But

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-10 Thread Peter Zijlstra
On Thu, Oct 10, 2019 at 10:55:15AM -0400, Steven Rostedt wrote: > 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

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-10 Thread Steven Rostedt
On Thu, 10 Oct 2019 10:55:15 -0400 Steven Rostedt 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 th

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-10 Thread Steven Rostedt
On Thu, 10 Oct 2019 10:55:15 -0400 Steven Rostedt wrote: > 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: > > > CPU0CPU1 >

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-10 Thread Steven Rostedt
On Thu, 10 Oct 2019 14:29:09 +0200 Peter Zijlstra wrote: > Yes, your code is anal about checking the NOPs, so you first have to Yep, because being paranoid about modifying code is always good ;-) > write NOPs before you can write CALLs, if it is enabled. But afaict you > really can do all that

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-10 Thread Peter Zijlstra
On Thu, Oct 10, 2019 at 08:50:11AM -0400, Steven Rostedt wrote: > On Thu, 10 Oct 2019 11:36:50 +0200 > Peter Zijlstra wrote: > > > load_module() > > > ... > > > complete_formation() > > > mutex_lock(&module_mutex); > > > ... > > > module_enable_ro(); > > > module_enable_nx();

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-10 Thread Steven Rostedt
On Wed, 9 Oct 2019 22:36:38 -0400 Steven Rostedt 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 bein

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-10 Thread Steven Rostedt
On Thu, 10 Oct 2019 11:36:50 +0200 Peter Zijlstra wrote: > > > > The reason is that ftrace_module_enable() is called after the module > > > > has set its text to read-only. There's subtle reasons that this needs > > > > to be called afterward, and we need to continue to do so. > > > > > > Plea

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-10 Thread Peter Zijlstra
On Thu, Oct 10, 2019 at 11:36:50AM +0200, Peter Zijlstra wrote: > On Thu, Oct 10, 2019 at 11:33:29AM +0200, Peter Zijlstra wrote: > > I don't see any reason what so ever.. > > > > load_module() > > ... > > complete_formation() > > mutex_lock(&module_mutex); > > ... > > module_enab

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-10 Thread Peter Zijlstra
On Thu, Oct 10, 2019 at 11:33:29AM +0200, Peter Zijlstra wrote: > On Thu, Oct 10, 2019 at 09:31:21AM +0200, Peter Zijlstra wrote: > > On Wed, Oct 09, 2019 at 10:36:38PM -0400, Steven Rostedt wrote: > > > From: Steven Rostedt (VMware) > > > > > > In the process of using text_poke_bp() for ftrace o

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-10 Thread Peter Zijlstra
On Thu, Oct 10, 2019 at 09:31:21AM +0200, Peter Zijlstra wrote: > On Wed, Oct 09, 2019 at 10:36:38PM -0400, Steven Rostedt wrote: > > From: Steven Rostedt (VMware) > > > > In the process of using text_poke_bp() for ftrace on x86, when > > performing the following action: > > > > # rmmod snd_hda

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-10 Thread Peter Zijlstra
On Thu, Oct 10, 2019 at 09:31:21AM +0200, Peter Zijlstra wrote: > On Wed, Oct 09, 2019 at 10:36:38PM -0400, Steven Rostedt wrote: > > From: Steven Rostedt (VMware) > > > > In the process of using text_poke_bp() for ftrace on x86, when > > performing the following action: > > > > # rmmod snd_hda

Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-10 Thread Peter Zijlstra
On Wed, Oct 09, 2019 at 10:36:38PM -0400, Steven Rostedt wrote: > From: Steven Rostedt (VMware) > > In the process of using text_poke_bp() for ftrace on x86, when > performing the following action: > > # rmmod snd_hda_codec_hdmi > # echo function > /sys/kernel/tracing/current_tracer > # modpr

[PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-09 Thread Steven Rostedt
From: Steven Rostedt (VMware) In the process of using text_poke_bp() for ftrace on x86, when performing the following action: # rmmod snd_hda_codec_hdmi # echo function > /sys/kernel/tracing/current_tracer # modprobe snd_hda_codec_hdmi It triggered this: BUG: unable to handle page fault fo