mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Aaron Tomlin <atomlin@redhat.com>, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 2/2] module: When modifying a module's text ignore modules which are going away too
Date: Wed, 26 Oct 2016 08:09:14 -0400	[thread overview]
Message-ID: <20161026080914.5bc68d0d@gandalf.local.home> (raw)
In-Reply-To: <87d1in538x.fsf@rustcorp.com.au>

On Wed, 26 Oct 2016 11:35:18 +1030
Rusty Russell <rusty@rustcorp.com.au> wrote:

> Aaron Tomlin <atomlin@redhat.com> writes:
> > By default, during the access permission modification of a module's core
> > and init pages, we only ignore modules that are malformed. There is no
> > reason not to extend this to modules which are going away too.  
> 
> Well, it depends on all the callers (ie. ftrace): is that also ignoring
> modules which are going away?
> 
> Otherwise, we set MODULE_STATE_GOING, ftrace walks all the modules and
> this one is still RO...
> 

Actually, looking into this more, you are correct. There's a
possibility in enabling ftrace after the module is about to go but
before ftrace_release_mod() is called (which will remove the module
text from the ftrace function list).

I don't see any reason for not allowing set_all_modules_text_rw() from
being called if a module is going. If a module is going, shouldn't its
text be rw anyway?

Perhaps just preventing it from turning into ro will be sufficient. And
remove the check from set_all_modules_text_rw().

-- Steve


> Thanks,
> Rusty.
> 
> > This patch makes both set_all_modules_text_rw() and
> > set_all_modules_text_ro() skip modules which are going away too.
> >
> > Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
> > ---
> >  kernel/module.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/module.c b/kernel/module.c
> > index ff93ab8..09c386b 100644
> > --- a/kernel/module.c
> > +++ b/kernel/module.c
> > @@ -1953,7 +1953,8 @@ void set_all_modules_text_rw(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_GOING)
> >  			continue;
> >  
> >  		frob_text(&mod->core_layout, set_memory_rw);
> > @@ -1969,7 +1970,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_GOING)
> >  			continue;
> >  
> >  		frob_text(&mod->core_layout, set_memory_ro);
> > -- 
> > 2.5.5  

  reply	other threads:[~2016-10-26 12:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20 16:18 [RFC PATCH 0/2] Possible race between load_module() error handling and kprobe registration ? Aaron Tomlin
2016-10-20 16:18 ` [RFC PATCH 1/2] module: Ensure a module's state is set accordingly during module coming cleanup code Aaron Tomlin
2016-10-26  0:54   ` Rusty Russell
2016-11-09 10:12     ` Jessica Yu
2016-11-16 15:49       ` Miroslav Benes
2016-11-23 23:41         ` Jessica Yu
2016-10-20 16:18 ` [RFC PATCH 2/2] module: When modifying a module's text ignore modules which are going away too Aaron Tomlin
2016-10-26  1:05   ` Rusty Russell
2016-10-26 12:09     ` Steven Rostedt [this message]
2016-10-27  9:36       ` [RFC PATCH v2 " Aaron Tomlin
2016-10-27 13:49         ` Steven Rostedt
2016-11-07 11:46           ` Aaron Tomlin
2016-11-09 10:40             ` Jessica Yu
2016-11-23 16:00               ` Steven Rostedt
2016-11-23 18:33                 ` Jessica Yu
2016-11-18  6:15         ` [RFC PATCH v2 2/2] " Rusty Russell

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=20161026080914.5bc68d0d@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=atomlin@redhat.com \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®