Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1327060

Re: [PATCH v2 2/2] livepatch/module: remove livepatch module notifier

From Miroslav Benes <mbenes@suse.cz>
Newsgroups linux.kernel
Subject Re: [PATCH v2 2/2] livepatch/module: remove livepatch module notifier
Date 2016-02-04 18:40 +0100
Message-ID <qYw2T-57e-45@gated-at.bofh.it> (permalink)
References <qXxNo-38h-5@gated-at.bofh.it> <qXxNo-38h-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, 1 Feb 2016, Jessica Yu wrote:

> +/* Called from the module loader during module coming/going states */
> +extern int klp_module_enable(struct module *mod);
> +extern void klp_module_disable(struct module *mod);

We do not use 'extern' keyword in header files. It is redundant. 
Unfortunately, the situation differs among header files and it is hard to 
be consistent.

> +	/*
> +	 * Each module has to know that the coming handler has
> +	 * been called. We never know what module will get
> +	 * patched by a new patch.
> +	 */
> +	mod->klp_alive = true;

This comment should fixed too.

Note: we still need klp_alive, because the race is still there even 
without notifiers.

> +void klp_module_disable(struct module *mod)
>  {
> -	int ret;
> -	struct module *mod = data;
>  	struct klp_patch *patch;
>  	struct klp_object *obj;
>  
> -	if (action != MODULE_STATE_COMING && action != MODULE_STATE_GOING)
> -		return 0;
> +	if (mod->state != MODULE_STATE_GOING)
> +		return;

This is similar to what Petr proposed. We must be in MODULE_STATE_GOING 
here. We could WARN here and return.

> diff --git a/kernel/module.c b/kernel/module.c
> index b05d466..71c77ed 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -3375,6 +3378,10 @@ static int complete_formation(struct module *mod, struct load_info *info)
>  	mutex_unlock(&module_mutex);
>  
>  	ftrace_module_enable(mod);
> +	err = klp_module_enable(mod);
> +	if (err)
> +		goto out;
> +

if (err)
	return err;

module_mutex is already unlocked so no need to jump to out.

Apart from these minor things and Petr's remarks it looks ok.

Thanks for fixing this.
Miroslav

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 2/2] livepatch/module: remove livepatch module notifier Jessica Yu <jeyu@redhat.com> - 2016-02-02 02:20 +0100
  Re: [PATCH v2 2/2] livepatch/module: remove livepatch module notifier Petr Mladek <pmladek@suse.com> - 2016-02-04 15:40 +0100
    Re: [PATCH v2 2/2] livepatch/module: remove livepatch module  notifier Steven Rostedt <rostedt@goodmis.org> - 2016-02-04 16:00 +0100
    Re: [PATCH v2 2/2] livepatch/module: remove livepatch module  notifier Miroslav Benes <mbenes@suse.cz> - 2016-02-04 17:50 +0100
    Re: livepatch/module: remove livepatch module notifier Jessica Yu <jeyu@redhat.com> - 2016-02-05 05:20 +0100
      Re: livepatch/module: remove livepatch module notifier Miroslav Benes <mbenes@suse.cz> - 2016-02-05 10:20 +0100
        Re: livepatch/module: remove livepatch module notifier Petr Mladek <pmladek@suse.com> - 2016-02-05 11:10 +0100
      Re: livepatch/module: remove livepatch module notifier Rusty Russell <rusty@rustcorp.com.au> - 2016-02-08 03:00 +0100
  Re: [PATCH v2 2/2] livepatch/module: remove livepatch module  notifier Miroslav Benes <mbenes@suse.cz> - 2016-02-04 18:40 +0100
  Re: [PATCH v2 2/2] livepatch/module: remove livepatch module notifier Josh Poimboeuf <jpoimboe@redhat.com> - 2016-02-04 22:00 +0100
    Re: [PATCH v2 2/2] livepatch/module: remove livepatch module  notifier Miroslav Benes <mbenes@suse.cz> - 2016-02-05 10:00 +0100

csiph-web