From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Tom Zanussi <tom.zanussi@linux.intel.com>,
Clark Williams <williams@redhat.com>,
Karim Yaghmour <karim.yaghmour@opersys.com>,
Brendan Gregg <bgregg@netflix.com>,
Joel Fernandes <joel@joelfernandes.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Yann Ylavic <ylavic.dev@gmail.com>,
linux-rt-users@vger.kernel.org
Subject: [PATCH v3 01/14] tracing: Do not reference event data in post call triggers
Date: Wed, 16 May 2018 11:00:13 -0400 [thread overview]
Message-ID: <20180516150159.352861970@goodmis.org> (raw)
In-Reply-To: 20180516150012.135869655@goodmis.org
[-- Attachment #1: 0001-tracing-Do-not-reference-event-data-in-post-call-tri.patch --]
[-- Type: text/plain, Size: 3605 bytes --]
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Trace event triggers can be called before or after the event has been
committed. If it has been called after the commit, there's a possibility
that the event no longer exists. Currently, the two post callers is the
trigger to disable tracing (traceoff) and the one that will record a stack
dump (stacktrace). Neither of them reference the trace event entry record,
as that would lead to a race condition that could pass in corrupted data.
To prevent any other users of the post data triggers from using the trace
event record, pass in NULL to the post call trigger functions for the event
record, as they should never need to use them in the first place.
This does not fix any bug, but prevents bugs from happening by new post call
trigger users.
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
include/linux/trace_events.h | 3 +--
kernel/trace/trace.h | 4 ++--
kernel/trace/trace_events_trigger.c | 6 ++----
3 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 2bde3eff564c..d1c442d9bd85 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -435,8 +435,7 @@ event_triggers_call(struct trace_event_file *file, void *rec,
struct ring_buffer_event *event);
extern void
event_triggers_post_call(struct trace_event_file *file,
- enum event_trigger_type tt,
- void *rec, struct ring_buffer_event *event);
+ enum event_trigger_type tt);
bool trace_event_ignore_this_pid(struct trace_event_file *trace_file);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 6fb46a06c9dc..24b666891eaf 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1334,7 +1334,7 @@ event_trigger_unlock_commit(struct trace_event_file *file,
trace_buffer_unlock_commit(file->tr, buffer, event, irq_flags, pc);
if (tt)
- event_triggers_post_call(file, tt, entry, event);
+ event_triggers_post_call(file, tt);
}
/**
@@ -1367,7 +1367,7 @@ event_trigger_unlock_commit_regs(struct trace_event_file *file,
irq_flags, pc, regs);
if (tt)
- event_triggers_post_call(file, tt, entry, event);
+ event_triggers_post_call(file, tt);
}
#define FILTER_PRED_INVALID ((unsigned short)-1)
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index d251cabcf69a..cc4148bfc01a 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -97,7 +97,6 @@ EXPORT_SYMBOL_GPL(event_triggers_call);
* event_triggers_post_call - Call 'post_triggers' for a trace event
* @file: The trace_event_file associated with the event
* @tt: enum event_trigger_type containing a set bit for each trigger to invoke
- * @rec: The trace entry for the event
*
* For each trigger associated with an event, invoke the trigger
* function registered with the associated trigger command, if the
@@ -108,8 +107,7 @@ EXPORT_SYMBOL_GPL(event_triggers_call);
*/
void
event_triggers_post_call(struct trace_event_file *file,
- enum event_trigger_type tt,
- void *rec, struct ring_buffer_event *event)
+ enum event_trigger_type tt)
{
struct event_trigger_data *data;
@@ -117,7 +115,7 @@ event_triggers_post_call(struct trace_event_file *file,
if (data->paused)
continue;
if (data->cmd_ops->trigger_type & tt)
- data->ops->func(data, rec, event);
+ data->ops->func(data, NULL, NULL);
}
}
EXPORT_SYMBOL_GPL(event_triggers_post_call);
--
2.17.0
next prev parent reply other threads:[~2018-05-16 15:00 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-16 15:00 [PATCH v3 00/14] tracing: Add triggers to trace_marker writes Steven Rostedt
2018-05-16 15:00 ` Steven Rostedt [this message]
2018-05-16 15:00 ` [PATCH v3 02/14] tracing: Add __find_event_file() to find event files without restrictions Steven Rostedt
2018-05-16 15:00 ` [PATCH v3 03/14] tracing: Have event_trace_init() called by trace_init_tracefs() Steven Rostedt
2018-05-16 15:00 ` [PATCH v3 04/14] tracing: Add brackets in ftrace event dynamic arrays Steven Rostedt
2018-05-16 15:00 ` [PATCH v3 05/14] tracing: Do not show filter file for ftrace internal events Steven Rostedt
2018-05-16 15:00 ` [PATCH v3 06/14] tracing: Add trigger file for trace_markers tracefs/ftrace/print Steven Rostedt
2018-05-16 15:00 ` [PATCH v3 07/14] tracing: Have zero size length in filter logic be full string Steven Rostedt
2018-05-16 15:00 ` [PATCH v3 08/14] tracing: Prevent further users of zero size static arrays in trace events Steven Rostedt
2018-05-16 15:00 ` [PATCH v3 09/14] tracing: Allow histogram triggers to access ftrace internal events Steven Rostedt
2018-05-16 15:00 ` [PATCH v3 10/14] tracing: Document trace_marker triggers Steven Rostedt
2018-05-16 15:42 ` [PATCH v3.5 " Steven Rostedt
2018-05-16 15:00 ` [PATCH v3 11/14] ftrace/selftest: Have the reset_trigger code be a bit more careful Steven Rostedt
2018-05-16 15:00 ` [PATCH v3 12/14] ftrace/selftest: Fix reset_trigger() to handle triggers with filters Steven Rostedt
2018-05-16 15:00 ` [PATCH v3 13/14] tracing/selftest: Add selftests to test trace_marker histogram triggers Steven Rostedt
2018-05-23 14:13 ` Masami Hiramatsu
2018-05-25 18:07 ` Steven Rostedt
2018-05-25 21:12 ` Steven Rostedt
2018-05-25 21:13 ` Steven Rostedt
2018-05-27 16:32 ` Masami Hiramatsu
2018-05-29 1:20 ` Steven Rostedt
2018-05-30 23:09 ` Masami Hiramatsu
2018-05-16 15:00 ` [PATCH v3 14/14] tracing/selftest: Add test to test hist trigger between kernel event and trace_marker Steven Rostedt
2018-05-23 14:15 ` Masami Hiramatsu
2018-05-25 18:15 ` Steven Rostedt
2018-05-25 18:19 ` Steven Rostedt
2018-05-27 16:33 ` Masami Hiramatsu
2018-05-23 5:41 ` [PATCH v3 00/14] tracing: Add triggers to trace_marker writes Namhyung Kim
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=20180516150159.352861970@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=bgregg@netflix.com \
--cc=joel@joelfernandes.org \
--cc=karim.yaghmour@opersys.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
--cc=tom.zanussi@linux.intel.com \
--cc=williams@redhat.com \
--cc=ylavic.dev@gmail.com \
/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).