lkml.org 
[lkml]   [2017]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] perf, tools: Avoid segfault on alias parse error
On Thu, Aug 17, 2017 at 01:25:39PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Aug 17, 2017 at 08:34:22AM -0700, Andi Kleen escreveu:
> > > Humm, but don't we have that checked?
> >
> > At least not in the case of the segfault below.
>
> Again:
>
> tools/perf/util/parse-events.c
>
> 2523 void parse_events_evlist_error(struct parse_events_evlist *data,
> 2524 int idx, const char *str)
> 2525 {
> 2526 struct parse_events_error *err = data->error;
> 2527
> 2528 if (!err)
> 2529 return;
> 2530 err->idx = idx;
> 2531 err->str = strdup(str);
> 2532 WARN_ONCE(!err->str, "WARNING: failed to allocate error string");
> 2533 }
>
> data->error _is_ being checked for NULL, and the hunk you added would

In the crash, data->error is not NULL, it's random stack contents
because the data types for the data pointer do not match
(parse_events_evlist vs parse_events_terms)

-Andi

\
 
 \ /
  Last update: 2017-08-17 19:03    [W:0.079 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site