Re: livepatch: Implement separate coming and going module notifiers
From: Steven Rostedt
Date: Fri Jan 29 2016 - 19:02:55 EST
On Fri, 29 Jan 2016 17:58:29 -0500
Jessica Yu <jeyu@xxxxxxxxxx> wrote:
> diff --git a/kernel/module.c b/kernel/module.c
> index 8358f46..eccd289 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -979,8 +979,12 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
> /* Final destruction now no one is using it. */
> if (mod->exit != NULL)
> mod->exit();
> blocking_notifier_call_chain(&module_notify_list,
> MODULE_STATE_GOING, mod);
> + klp_module_disable(mod);
> + ftrace_release_mod(mod);
> +
> async_synchronize_full();
>
> /* Store the name of the last unloaded module for diagnostic purposes */
> @@ -3371,6 +3375,13 @@ static int complete_formation(struct module *mod, struct load_info *info)
> mod->state = MODULE_STATE_COMING;
> mutex_unlock(&module_mutex);
>
> + ftrace_module_enable(mod);
> + err = klp_module_enable(mod); // write all relocations before calling coming notifiers
> + if (err) {
> + ftrace_release_mod(mod);
This isn't needed. If complete_formation() fails with an error, then
its caller (load_module) will do the clean up and call
ftrace_release_mod().
-- Steve
> + goto out;
> + }
> +
> blocking_notifier_call_chain(&module_notify_list,
> MODULE_STATE_COMING, mod);
> return 0;
>