Re: [PATCH 00/10] ftrace: Add register_ftrace_direct()

From: Josh Poimboeuf
Date: Mon Nov 11 2019 - 09:15:59 EST


On Mon, Nov 11, 2019 at 09:47:28AM +0100, Peter Zijlstra wrote:
> On Fri, Nov 08, 2019 at 04:51:00PM -0600, Josh Poimboeuf wrote:
>
> > From: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> > Subject: [PATCH] ftrace/x86: Tell objtool to ignore nondeterministic ftrace stack layout
> >
> > Objtool complains about the new ftrace direct trampoline code:
> >
> > arch/x86/kernel/ftrace_64.o: warning: objtool: ftrace_regs_caller()+0x190: stack state mismatch: cfa1=7+16 cfa2=7+24
> >
> > Typically, code has a deterministic stack layout, such that at a given
> > instruction address, the stack frame size is always the same.
> >
> > That's not the case for the new ftrace_regs_caller() code after it
> > adjusts the stack for the direct case. Just plead ignorance and assume
> > it's always the non-direct path. Note this creates a tiny window for
> > ORC to get confused.
>
> How is that not a problem for livepatch?

If this code were preempted at the point where the ORC data is wrong,
and then livepatch tried to unwind it, the reliable unwinder would error
out because it doesn't get all the way to the user-space pt_regs. Then
it will just try again later.

I view this as a temporary fix; the code should be restructured to
follow normal rules.

--
Josh