diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-08-17 14:22:50 -0300 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2017-11-26 13:50:20 +0000 |
commit | 607fc3dc95fa69e8b4cf531718c3d90f513a9361 (patch) | |
tree | fb39944276a8ef2975870180df385304ac28507f /tools | |
parent | 97330896a76dc0a44209361233b38e9eb4a0f637 (diff) | |
download | linux-stable-607fc3dc95fa69e8b4cf531718c3d90f513a9361.tar.gz linux-stable-607fc3dc95fa69e8b4cf531718c3d90f513a9361.tar.bz2 linux-stable-607fc3dc95fa69e8b4cf531718c3d90f513a9361.zip |
perf events parse: Use just one parse events state struct
commit d17d0878f456c8227345b6c76b918ec068fa0abd upstream.
Andi reported problems when parse errors were detected with vendor
events (json), because in the yyparse/parse_events_parse function we
dereferenced the _data parameter to two different structs, with
different layouts, which ended up making parse_events_evlist->error to
point to random stack addresses.
Fix it by making _data to always be struct parse_events_state, changing
the only place where 'struct parse_events_term' was used in
parse_events.y.
Reported-by: Andi Kleen <ak@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-bc27lshz823hxl8n9nkelcgh@git.kernel.org
Fixes: 90e2b22dee90 ("perf/tool: Add support to reuse event grammar to parse out terms")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/parse-events.c | 2 | ||||
-rw-r--r-- | tools/perf/util/parse-events.h | 5 | ||||
-rw-r--r-- | tools/perf/util/parse-events.y | 2 |
3 files changed, 3 insertions, 6 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index e2fc0a4e2d63..4c498e61e340 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -908,7 +908,7 @@ static int parse_events__scanner(const char *str, void *data, int start_token) */ int parse_events_terms(struct list_head *terms, const char *str) { - struct parse_events_terms data = { + struct parse_events_state data = { .terms = NULL, }; int ret; diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index 4c90df2ca2b1..464c6ffdcab7 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -65,10 +65,7 @@ struct parse_events_state { struct list_head list; int idx; int nr_groups; -}; - -struct parse_events_terms { - struct list_head *terms; + struct list_head *terms; }; int parse_events__is_hardcoded_term(struct parse_events_term *term); diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 947ccbd2cddd..9af659b1c478 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -346,7 +346,7 @@ PE_RAW start_terms: event_config { - struct parse_events_terms *data = _data; + struct parse_events_state *data = _data; data->terms = $1; } |