Skip to content

Commit

Permalink
perf events parse: Use just one parse events state struct
Browse files Browse the repository at this point in the history
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: 90e2b22 ("perf/tool: Add support to reuse event grammar to parse out terms")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Arnaldo Carvalho de Melo committed Aug 17, 2017
1 parent 5d369a7 commit d17d087
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tools/perf/util/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,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;
Expand Down
5 changes: 1 addition & 4 deletions tools/perf/util/parse-events.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ struct parse_events_state {
int nr_groups;
struct parse_events_error *error;
struct perf_evlist *evlist;
};

struct parse_events_terms {
struct list_head *terms;
struct list_head *terms;
};

void parse_events__shrink_config_terms(void);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/parse-events.y
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ opt_event_config:

start_terms: event_config
{
struct parse_events_terms *data = _data;
struct parse_events_state *data = _data;
data->terms = $1;
}

Expand Down

0 comments on commit d17d087

Please sign in to comment.