[PATCH] livepatch: do relocation when initializing the patch: was: Re: [PATCHv4 2/3] kernel: add support for live patching

From: Petr Mladek
Date: Fri Nov 28 2014 - 12:19:17 EST


On Fri 2014-11-28 18:07:37, Petr Mladek wrote:
> On Tue 2014-11-25 11:15:08, Seth Jennings wrote:
> > This commit introduces code for the live patching core. It implements
> > an ftrace-based mechanism and kernel interface for doing live patching
> > of kernel and kernel module functions.

[...]

> > +static int klp_enable_object(struct module *pmod, struct klp_object *obj)
> > +{
> > + struct klp_func *func;
> > + int ret;
> > +
> if (WARN_ON(obj->state != KLP_DISABLED))
> return -EINVAL;
>
> > + if (WARN_ON(!obj->mod && obj->name))
> > + return -EINVAL;
> > +
> > + if (obj->relocs) {
> > + ret = klp_write_object_relocations(pmod, obj);
>
> I was curious why the relocation is here. I think that the motivation
> was to safe the call when handling comming modules.
>
> IMHO, more clean solution would be to do this in klp_init_object().
> It will also cause removing the "pmod" parameter and this function
> will be more symmetric with klp_disable_object();
>
> I was curious how it would work, so I prepared a patch. I will send
> it in separate mail.

The patch is below. Again, merge it into the original patch if you
agree with the idea, please.