linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Tom Zanussi <zanussi@kernel.org>
Subject: Re: [PATCH] tracing: Fix race where histograms can be called before the event
Date: Thu, 24 Nov 2022 08:39:16 +0900	[thread overview]
Message-ID: <20221124083916.667a68cfe38f6fadd84000f4@kernel.org> (raw)
In-Reply-To: <20221123164323.03450c3a@gandalf.local.home>

On Wed, 23 Nov 2022 16:43:23 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> 
> commit 94eedf3dded5 ("tracing: Fix race where eprobes can be called before
> the event") fixed an issue where if an event is soft disabled, and the
> trigger is being added, there's a small window where the event sees that
> there's a trigger but does not see that it requires reading the event yet,
> and then calls the trigger with the record == NULL.
> 
> This could be solved with adding memory barriers in the hot path, or to
> make sure that all the triggers requiring a record check for NULL. The
> latter was chosen.
> 
> Commit 94eedf3dded5 set the eprobe trigger handle to check for NULL, but
> the same needs to be done with histograms.
> 
> Link: https://lore.kernel.org/linux-trace-kernel/20221118211809.701d40c0f8a757b0df3c025a@kernel.org/
> 
> Cc: stable@vger.kernel.org
> Fixes: 7491e2c442781 ("tracing: Add a probe that attaches to trace events")
> Reported-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

I confirmed that other trigger callbacks only use the event_trigger_data,
So this looks good to me.

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Thank you!

> ---
>  kernel/trace/trace_events_hist.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index 087c19548049..1c82478e8dff 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -5143,6 +5143,9 @@ static void event_hist_trigger(struct event_trigger_data *data,
>  	void *key = NULL;
>  	unsigned int i;
>  
> +	if (unlikely(!rbe))
> +		return;
> +
>  	memset(compound_key, 0, hist_data->key_size);
>  
>  	for_each_hist_key_field(i, hist_data) {
> -- 
> 2.35.1
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

      reply	other threads:[~2022-11-23 23:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 21:43 [PATCH] tracing: Fix race where histograms can be called before the event Steven Rostedt
2022-11-23 23:39 ` Masami Hiramatsu [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=20221124083916.667a68cfe38f6fadd84000f4@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=zanussi@kernel.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).