diff options
author | Tom Zanussi <tom.zanussi@linux.intel.com> | 2019-04-18 10:18:50 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-06-19 08:18:04 +0200 |
commit | 86895090621c80ba00ffac078443f91945c356ac (patch) | |
tree | 0fbe3d6a4a45c4ce114341ac10eb5479939a633a | |
parent | b64df8133c2e8263febbd6d279554d257b85417b (diff) | |
download | linux-rpi3-86895090621c80ba00ffac078443f91945c356ac.tar.gz linux-rpi3-86895090621c80ba00ffac078443f91945c356ac.tar.bz2 linux-rpi3-86895090621c80ba00ffac078443f91945c356ac.zip |
tracing: Prevent hist_field_var_ref() from accessing NULL tracing_map_elts
[ Upstream commit 55267c88c003a3648567beae7c90512d3e2ab15e ]
hist_field_var_ref() is an implementation of hist_field_fn_t(), which
can be called with a null tracing_map_elt elt param when assembling a
key in event_hist_trigger().
In the case of hist_field_var_ref() this doesn't make sense, because a
variable can only be resolved by looking it up using an already
assembled key i.e. a variable can't be used to assemble a key since
the key is required in order to access the variable.
Upper layers should prevent the user from constructing a key using a
variable in the first place, but in case one slips through, it
shouldn't cause a NULL pointer dereference. Also if one does slip
through, we want to know about it, so emit a one-time warning in that
case.
Link: http://lkml.kernel.org/r/64ec8dc15c14d305295b64cdfcc6b2b9dd14753f.1555597045.git.tom.zanussi@linux.intel.com
Reported-by: Vincent Bernat <vincent@bernat.ch>
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | kernel/trace/trace_events_hist.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 11853e90b649..3f34cfb66a85 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -1632,6 +1632,9 @@ static u64 hist_field_var_ref(struct hist_field *hist_field, struct hist_elt_data *elt_data; u64 var_val = 0; + if (WARN_ON_ONCE(!elt)) + return var_val; + elt_data = elt->private_data; var_val = elt_data->var_ref_vals[hist_field->var_ref_idx]; |