Re: [PATCH v2] objtool,ftrace: Implement UNWIND_HINT_RET_OFFSET
From: Peter Zijlstra
Date: Wed Apr 01 2020 - 11:38:22 EST
On Wed, Apr 01, 2020 at 09:39:16AM -0500, Josh Poimboeuf wrote:
> On Wed, Apr 01, 2020 at 04:22:26PM +0200, Peter Zijlstra wrote:
> > > > @@ -366,6 +367,13 @@ create_trampoline(struct ftrace_ops *ops
> > > > if (WARN_ON(ret < 0))
> > > > goto fail;
> > > >
> > > > + if (ops->flags & FTRACE_OPS_FL_SAVE_REGS) {
> > > > + ip = ftrace_regs_caller_ret;
> > > > + ret = probe_kernel_read(ip, (void *)retq, RET_SIZE);
> > > > + if (WARN_ON(ret < 0))
> > > > + goto fail;
> > > > + }
> > > > +
> Right, but 'ip' needs to point to the trampoline's version of
> 'ftrace_regs_caller_ret', not the original ftrace_64 version.
Duh,
ip = trampline + (ftrace_regs_caller_ret - ftrace_regs_caller);
it is.
Luckily this would've triggerd a splat the first time I'd have actually
booted this, because the regular text is RO, while the trampoline is
still RW here. Still, good spotting.