Re: [PATCH] livepatch: add (un)patch hooks

From: Josh Poimboeuf
Date: Thu Jul 20 2017 - 13:04:22 EST


On Thu, Jul 20, 2017 at 05:50:04PM +0200, Petr Mladek wrote:
> On Wed 2017-07-19 23:17:23, Josh Poimboeuf wrote:
> > - patching otherwise unpatchable code (i.e., assembly)
> >
> > In many/most cases, it seems like stop_machine() would be very useful
> > to avoid concurrency issues.
>
> I am not sure if stop_machine() would help here. It would make sense
> in kPatch where also the ftrace handlers are added during
> stop_machine(). Then it is possible to synchronize both operations
> (hooks, enabling ftrace handlers) and do everything "atomically".
>
> IMHO, the big advantage of livepatch framework is that stop_machine()
> is not needed. I hope that it will stay this way.
>
> Also it might need some additional support. You would want to stop
> the machine to make sure that it is safe to do a change. Then
> we might need to check stacks, ...

Don't worry. I much prefer our current consistency model to kpatch, and
I have no intention of changing it :-)

That said, for the hooks, I still think stop_machine() will be helpful
in some cases where you need to ensure no other code is running. Like
the stack_segment patch I posted, for example.

Anyway I'm not suggesting we do the stop_machine() in livepatch code
itself. I'm just hoping it will work from a hook, in case the patch
author needs to do it as a last resort.

--
Josh