Re: [PATCH] tracing: Fix race where eprobes can be called before the event

From: Steven Rostedt
Date: Wed Nov 23 2022 - 16:03:00 EST


On Fri, 18 Nov 2022 21:18:09 +0900
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> wrote:

> This looks good to me.
>
> Acked-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
>
> BTW, would other trigger callbacks also need to add similar checks?

I just checked, and yes, I think that histograms (the only other trigger
that has EVENT_CMD_FL_NEEDS_REC set) has the same issue, and requires:

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) {


I'll add that next.

-- Steve