[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZIlhZ6gbhfvmZP2r@krava>
Date: Wed, 14 Jun 2023 08:42:47 +0200
From: Jiri Olsa <olsajiri@...il.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Jiri Olsa <olsajiri@...il.com>,
"Masami Hiramatsu (Google)" <mhiramat@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
Linux Trace Kernel <linux-trace-kernel@...r.kernel.org>,
bpf@...r.kernel.org
Subject: Re: [RFC] fprobe call of rethook_try_get faults
On Tue, Jun 13, 2023 at 05:48:44PM -0400, Steven Rostedt wrote:
> On Wed, 7 Jun 2023 09:42:30 -0700
> Jiri Olsa <olsajiri@...il.com> wrote:
>
> > I can't really reliable reproduce this, but while checking the code, I wonder
> > we should call rethook_free only after we call unregister_ftrace_function like
> > in the patch below
>
> Yeah, I think you're right!
>
> >
> > jirka
> >
> >
> > ---
> > diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
> > index 18d36842faf5..0121e8c0d54e 100644
> > --- a/kernel/trace/fprobe.c
> > +++ b/kernel/trace/fprobe.c
> > @@ -364,19 +364,13 @@ int unregister_fprobe(struct fprobe *fp)
> > fp->ops.saved_func != fprobe_kprobe_handler))
> > return -EINVAL;
> >
> > - /*
> > - * rethook_free() starts disabling the rethook, but the rethook handlers
> > - * may be running on other processors at this point. To make sure that all
> > - * current running handlers are finished, call unregister_ftrace_function()
> > - * after this.
> > - */
> > - if (fp->rethook)
> > - rethook_free(fp->rethook);
>
> The above only waits for RCU to finish and then starts to free rethook.
>
> This also means that something could be on the trampoline already and was
> preempted. It could be that this code path gets preempted. Anyway, I don't
> see how freeing rethook is safe before disabling all users.
>
> Reviewed-by: Steven Rostedt (Google) <rostedt@...dmis.org>
thanks, I'll send formal patch
jirka
>
> -- Steve
>
>
> > -
> > ret = unregister_ftrace_function(&fp->ops);
> > if (ret < 0)
> > return ret;
> >
> > + if (fp->rethook)
> > + rethook_free(fp->rethook);
> > +
> > ftrace_free_filter(&fp->ops);
> >
> > return ret;
>
Powered by blists - more mailing lists