Re: [PATCH v2] livepatch: allow removal of a disabled patch

From: Miroslav Benes
Date: Wed Jun 01 2016 - 07:43:18 EST


On Wed, 1 Jun 2016, Christopher Arges wrote:

> On Wed, Jun 01, 2016 at 10:31:59AM +0200, Miroslav Benes wrote:
> >
> > diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c
> > index 92819bb0961b..6cc49d253195 100644
> > --- a/kernel/livepatch/transition.c
> > +++ b/kernel/livepatch/transition.c
> > @@ -197,13 +197,21 @@ void klp_complete_transition(void)
> > struct klp_func *func;
> > struct task_struct *g, *task;
> > unsigned int cpu;
> > + bool is_immediate = false;
> >
> > if (klp_transition_patch->immediate)
> > goto done;
> >
> > - klp_for_each_object(klp_transition_patch, obj)
> > - klp_for_each_func(obj, func)
> > + klp_for_each_object(klp_transition_patch, obj) {
> > + klp_for_each_func(obj, func) {
> > func->transition = false;
> > + if (func->immediate)
> > + is_immediate = true;
>
> Once an immediate function is found you could return from this function since
> releasing a reference from the livepatch module is no longer possible.

That is true, but I think we should tidy up after the patching process
even in this case. That is clear all func->transition, task->patch_state
and task->TIF_PATCH_PENDING flags. These all could be set if
patch->immediate is false and one of the func->immediate is true.

Regards,
Miroslav