Re: [PATCH 1/3 v7] ftrace: Have the callbacks receive a struct ftrace_regs instead of pt_regs

From: Steven Rostedt
Date: Thu Nov 19 2020 - 09:08:03 EST


On Thu, 19 Nov 2020 12:05:44 +0100
Petr Mladek <pmladek@xxxxxxxx> wrote:

> > void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
> > - struct ftrace_ops *ops, struct pt_regs *regs)
> > + struct ftrace_ops *ops, struct ftrace_regs *fregs)
> > {
> > int bit;
> > bool lr_saver = false;
> > struct kprobe *p;
> > struct kprobe_ctlblk *kcb;
> > + struct pt_regs *regs;
> >
> > bit = ftrace_test_recursion_trylock(ip, parent_ip);
> > if (bit < 0)
> > return;
> >
> > + regs = ftrace_get_regs(fregs);
>
> Should we check for NULL here?
> Same in all callers?

If regs is NULL that's a major bug.

It's no different than what we have today. If you set FL_SAVE_REGS, then
the regs parameter will have regs. If you don't, it will be NULL. We don't
check regs for NULL today, so we shouldn't need to check regs for NULL with
this.

One of my bootup tests checks if this works. I work hard to make sure that
regs is set for everything that wants it, otherwise bad things happen.

In other words, the functionality in this regard hasn't changed with this
patch.

-- Steve


>
> > preempt_disable_notrace();
> > p = get_kprobe((kprobe_opcode_t *)ip);
> > if (!p) {
>
> Otherwise, the patch is pretty strightforard and looks good to me.