public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Miroslav Benes <mbenes@suse.cz>
Cc: Jessica Yu <jeyu@kernel.org>,
	linux-kernel@vger.kernel.org, jpoimboe@redhat.com,
	jikos@kernel.org, pmladek@suse.com, rostedt@goodmis.org,
	ast@kernel.org, daniel@iogearbox.net,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>
Subject: Re: [RFC][PATCH] module: Propagate MODULE_STATE_COMING notifier errors
Date: Wed, 19 Jun 2019 14:01:31 +0200	[thread overview]
Message-ID: <20190619120131.GS3463@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20190619113508.GP3463@hirez.programming.kicks-ass.net>

On Wed, Jun 19, 2019 at 01:35:08PM +0200, Peter Zijlstra wrote:
> On Wed, Jun 19, 2019 at 01:33:24PM +0200, Peter Zijlstra wrote:
> > How's something like so:
> > 
> > diff --git a/kernel/module.c b/kernel/module.c
> > index 80c7c09584cf..eba6560c89da 100644
> > --- a/kernel/module.c
> > +++ b/kernel/module.c
> > @@ -3631,16 +3631,28 @@ static int complete_formation(struct module *mod, struct load_info *info)
> >  
> >  static int prepare_coming_module(struct module *mod)
> >  {
> > -	int err;
> > +	struct blocking_notifier_head *nh = &module_notify_list;
> > +	int err, nr;
> >  
> >  	ftrace_module_enable(mod);
> >  	err = klp_module_coming(mod);
> >  	if (err)
> >  		return err;
> >  
> > -	blocking_notifier_call_chain(&module_notify_list,
> > -				     MODULE_STATE_COMING, mod);
> > -	return 0;
> > +	if (!rcu_access_pointer(nh->head))
> > +		return 0;
> > +
> > +	down_read(&nh->rwsem);
> > +	ret = notifier_call_chain(&nh->head, MODULE_STATE_COMING, mod, -1, &nr);
> > +	if (ret & NOTIFIER_STOP_MASK)
> 
> It compiles _lots_ better with s/ret/err/ on.
> 
> > +		notifier_call_chain(&nh->head, MODULE_STATE_GOING, mod, nr, NULL);
> > +	up_read(&nh->rwsem);
> > +
> > +	err = notifier_to_err(err);
> > +	if (err)
> > +		klp_module_going(mod);
> > +
> > +	return err;
> >  }
> >  
> >  static int unknown_module_param_cb(char *param, char *val, const char *modname,

Rafael, how is kernel/power/user.c snapshot_open() not broken (any any
other __pm_notifier_call_chain() user)?

afaict the __pm_notifier_call_chain() thing is broken in two ways:

 - there can be a change to the notifier list between the PREPARE and
   POST iteration

 - the error value isn't put through notifier_to_errno().

  reply	other threads:[~2019-06-19 12:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17  9:03 [RFC][PATCH] module: Propagate MODULE_STATE_COMING notifier errors Peter Zijlstra
2019-06-17 23:18 ` Steven Rostedt
2019-06-19 11:12 ` Miroslav Benes
2019-06-19 11:23   ` Peter Zijlstra
2019-06-19 11:33     ` Peter Zijlstra
2019-06-19 11:35       ` Peter Zijlstra
2019-06-19 12:01         ` Peter Zijlstra [this message]
2019-06-21 16:31     ` Jessica Yu
2019-06-19 11:25   ` Peter Zijlstra
2019-06-19 11:56   ` Petr Mladek
2019-06-21 16:18   ` 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=20190619120131.GS3463@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jeyu@kernel.org \
    --cc=jikos@kernel.org \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=pmladek@suse.com \
    --cc=rjw@rjwysocki.net \
    --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