lkml.org 
[lkml]   [2016]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 2/2] livepatch/module: remove livepatch module notifier
On Thu, 4 Feb 2016, Petr Mladek wrote:

> On Mon 2016-02-01 20:17:36, Jessica Yu wrote:
> >
> >
> > - if (patch->state == KLP_DISABLED)
> > - goto disabled;
> > + ret = klp_init_object_loaded(patch, obj);
> > + if (ret) {
> > + pr_warn("failed to initialize patch '%s' for module '%s' (%d)\n",
> > + patch->mod->name, obj->mod->name, ret);
> > + goto err;
> > + }
> > +
> > + if (patch->state == KLP_DISABLED)
> > + break;
> >
> > - pr_notice("reverting patch '%s' on unloading module '%s'\n",
> > - pmod->name, mod->name);
> > + pr_notice("applying patch '%s' to loading module '%s'\n",
> > + patch->mod->name, obj->mod->name);
> >
> > - klp_disable_object(obj);
> > + ret = klp_enable_object(obj);
> > + if (ret) {
> > + pr_warn("failed to apply patch '%s' to module '%s' (%d)\n",
> > + patch->mod->name, obj->mod->name, ret);
> > + goto err;
> > + }
> > +
> > + break;
> > + }
> > + }
> > +
> > + mutex_unlock(&klp_mutex);
> >
> > -disabled:
> > - klp_free_object_loaded(obj);
> > + return 0;
> > +
> > +err:
> > + /*
> > + * If a patch is unsuccessfully applied, return
> > + * error to the module loader.
> > + */
> > + obj->mod = NULL;
> > + pr_warn("patch '%s' is in an inconsistent state!\n", patch->mod->name);
>
> This message is not correct. The module will not get loaded
> when the patch is not applied.

Yes, because we are in a better situation with this patch. We actually
return an error and refuse to load the module. Message should take that
into account.

> Instead, we need to revert all the operations that has already
> been done for this module. Note that the module stayed loaded
> before, so we did not need to release any memory or revert
> any ftrace call registration but we need to do so now!

Actually, I think the code is correct. If klp_init_object_loaded() there
is no problem because we only write relocations there (which are written
to the module being loaded) and resolve symbols via kallsyms. Nothing to
revert there and it could be done again.

If klp_enable_object() fails, all the relevant error handling was already
done there. See the call to klp_disable_object() if klp_enable_function()
fails there.

Miroslav

\
 
 \ /
  Last update: 2016-02-04 18:21    [W:0.659 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site