Re: [PATCH v3 13/15] livepatch: change to a per-task consistency model

Petr Mladek
2017-01-10T10:40:04Z

On Fri 2017-01-06 14:07:34, Josh Poimboeuf wrote:
> On Fri, Dec 23, 2016 at 11:18:03AM +0100, Petr Mladek wrote:
> > On Fri 2016-12-23 10:24:35, Miroslav Benes wrote:
> > > > > > diff --git a/kernel/livepatch/patch.c b/kernel/livepatch/patch.c
> > > > > > index 5efa262..e79ebb5 100644
> > > > > > --- a/kernel/livepatch/patch.c
> > > > > > +++ b/kernel/livepatch/patch.c
> > > > > > @@ -29,6 +29,7 @@
> > > > > > #include <linux/bug.h>
> > > > > > #include <linux/printk.h>
> > > > > > #include "patch.h"
> > > > > > +#include "transition.h"
> > > > > >
> > > > > > static LIST_HEAD(klp_ops);
> > > > > >
> > > > > > @@ -54,15 +55,53 @@ static void notrace klp_ftrace_handler(unsigned long ip,
> > > > > > {
> > > > > > struct klp_ops *ops;
> > > > > > struct klp_func *func;
> > > > > > + int patch_state;
> > > > > >
> > > > > > ops = container_of(fops, struct klp_ops, fops);
> > > > > >
> > > > > > rcu_read_lock();
> > > > > > +
> > > > > > func = list_first_or_null_rcu(&ops->func_stack, struct klp_func,
> > > > > > stack_node);
> > > > > > - if (WARN_ON_ONCE(!func))
> > > > > > +
> > > > > > + if (!func)
> > > > > > goto unlock;
> > > > >

> Yeah, I'm thinking we should keep the warning to catch any bugs in case
> any of our ftrace assumptions change. Maybe I should add a comment:
>
> /*
> * func can never be NULL because preemption should be disabled
> * here and unregister_ftrace_function() does the equivalent of
> * a synchronize_sched() before the func_stack removal.
> */
> if (WARN_ON_ONCE(!func))
> goto unlock;

Sounds reasonable to me.

Best Regards,
Petr