Re: [PATCH 6/9] livepatch/ftrace: Add recursion protection to the ftrace callback

Steven Rostedt
2020-10-29T14:37:49Z

On Thu, 29 Oct 2020 14:51:06 +0100 (CET)
Miroslav Benes <mbenes@suse.cz> wrote:

> > index b552cf2d85f8..6c0164d24bbd 100644
> > --- a/kernel/livepatch/patch.c
> > +++ b/kernel/livepatch/patch.c
> > @@ -45,9 +45,13 @@ static void notrace klp_ftrace_handler(unsigned long ip,
> > struct klp_ops *ops;
> > struct klp_func *func;
> > int patch_state;
> > + int bit;
> >
> > ops = container_of(fops, struct klp_ops, fops);
> >
> > + bit = ftrace_test_recursion_trylock();
> > + if (bit < 0)
> > + return;
>
> This means that the original function will be called in case of recursion.
> That's probably fair, but I'm wondering if we should at least WARN about
> it.

It's probably what happens today. But if you add a WARN_ON_ONCE() it may
not hurt.

I also plan on adding code that reports when recursion has happened,
because even if it's not a problem, recursion adds extra overhead.

-- Steve