From: Jiri Olsa <olsajiri@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Jiri Olsa <olsajiri@gmail.com>,
"Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>,
bpf@vger.kernel.org
Subject: Re: [RFC] fprobe call of rethook_try_get faults
Date: Wed, 14 Jun 2023 08:42:47 +0200 [thread overview]
Message-ID: <ZIlhZ6gbhfvmZP2r@krava> (raw)
In-Reply-To: <20230613174844.4d50991d@gandalf.local.home>
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@gmail.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@goodmis.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;
>
prev parent reply other threads:[~2023-06-14 6:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 16:42 [RFC] fprobe call of rethook_try_get faults Jiri Olsa
2023-06-13 21:48 ` Steven Rostedt
2023-06-14 6:42 ` Jiri Olsa [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZIlhZ6gbhfvmZP2r@krava \
--to=olsajiri@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).