Skip to content

Commit 3843083

Browse files
Tom Zanussirostedt
authored andcommitted
tracing: Check that number of vals matches number of synth event fields
Commit 7276531('tracing: Consolidate trace() functions') inadvertently dropped the synth_event_trace() and synth_event_trace_array() checks that verify the number of values passed in matches the number of fields in the synthetic event being traced, so add them back. Link: http://lkml.kernel.org/r/32819cac708714693669e0dfe10fe9d935e94a16.1581720155.git.zanussi@kernel.org Signed-off-by: Tom Zanussi <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 1d9d4c9 commit 3843083

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

kernel/trace/trace_events_hist.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,11 @@ int synth_event_trace(struct trace_event_file *file, unsigned int n_vals, ...)
18781878
return ret;
18791879
}
18801880

1881+
if (n_vals != state.event->n_fields) {
1882+
ret = -EINVAL;
1883+
goto out;
1884+
}
1885+
18811886
va_start(args, n_vals);
18821887
for (i = 0, n_u64 = 0; i < state.event->n_fields; i++) {
18831888
u64 val;
@@ -1914,7 +1919,7 @@ int synth_event_trace(struct trace_event_file *file, unsigned int n_vals, ...)
19141919
}
19151920
}
19161921
va_end(args);
1917-
1922+
out:
19181923
__synth_event_trace_end(&state);
19191924

19201925
return ret;
@@ -1953,6 +1958,11 @@ int synth_event_trace_array(struct trace_event_file *file, u64 *vals,
19531958
return ret;
19541959
}
19551960

1961+
if (n_vals != state.event->n_fields) {
1962+
ret = -EINVAL;
1963+
goto out;
1964+
}
1965+
19561966
for (i = 0, n_u64 = 0; i < state.event->n_fields; i++) {
19571967
if (state.event->fields[i]->is_string) {
19581968
char *str_val = (char *)(long)vals[i];
@@ -1984,7 +1994,7 @@ int synth_event_trace_array(struct trace_event_file *file, u64 *vals,
19841994
n_u64++;
19851995
}
19861996
}
1987-
1997+
out:
19881998
__synth_event_trace_end(&state);
19891999

19902000
return ret;

0 commit comments

Comments
 (0)