Thread (3 messages) 3 messages, 2 authors, 2023-02-20

[PATCH] tracing: Check for NULL field_name in __synth_event_add_val()

flat view
STALE1330d

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2023-02-18 15:59:30
Also in: lkml
Subsystem: the rest, tracing · Maintainers: Linus Torvalds, Steven Rostedt, Masami Hiramatsu

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

It is possible that the field_name passed into __synth_event_add_val() can
be NULL with the trace_state set to add_name (possibly set from a previous
call), in which case it needs to be checked.

Cc: stable@vger.kernel.org
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=217053
Fixes: 8dcc53ad956d2 ("tracing: Add synth_event_trace() and related functions")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---

Tom, can you review this. Is there a legitimate case where you can have a
previous call set "add_name" but the next call not require it? This patch
assumes that it can't.

 kernel/trace/trace_events_synth.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index 70bddb25d9c0..fa28c1da06d2 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -1982,6 +1982,10 @@ static int __synth_event_add_val(const char *field_name, u64 val,
 
 	event = trace_state->event;
 	if (trace_state->add_name) {
+		if (!field_name) {
+			ret = -EINVAL;
+			goto out;
+		}
 		for (i = 0; i < event->n_fields; i++) {
 			field = event->fields[i];
 			if (strcmp(field->name, field_name) == 0)
-- 
2.39.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help