[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191112110506.GI9365@kernel.org>
Date: Tue, 12 Nov 2019 08:05:06 -0300
From: Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
To: Ian Rogers <irogers@...gle.com>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>,
Jiri Olsa <jolsa@...hat.com>, He Kuang <hekuang@...wei.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Namhyung Kim <namhyung@...nel.org>,
Andi Kleen <ak@...ux.intel.com>,
LKML <linux-kernel@...r.kernel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>,
Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH] perf tools: avoid reading out of scope array
Em Mon, Nov 11, 2019 at 12:34:23PM -0800, Ian Rogers escreveu:
> Thanks Arnaldo, this patch shouldn't be added. It was replaced with
> the longer v2 patch that addressed the memory issues properly. That
> was followed by a number of improved versions.
Thanks for checking,
- Arnaldo
> Ian
>
> On Mon, Nov 11, 2019 at 6:25 AM Arnaldo Carvalho de Melo
> <arnaldo.melo@...il.com> wrote:
> >
> > Em Wed, Oct 23, 2019 at 10:29:12AM +0200, Jiri Olsa escreveu:
> > > On Thu, Oct 17, 2019 at 10:05:31AM -0700, Ian Rogers wrote:
> > > > Modify tracepoint name into 2 sys components and assemble at use. This
> > > > avoids the sys_name array being out of scope at the point of use.
> > > > Bug caught with LLVM's address sanitizer with fuzz generated input of
> > > > ":cs\1" to parse_events.
> > > >
> > > > Signed-off-by: Ian Rogers <irogers@...gle.com>
> > > > ---
> > > > tools/perf/util/parse-events.y | 36 +++++++++++++++++++++++-----------
> > > > 1 file changed, 25 insertions(+), 11 deletions(-)
> > > >
> > > > diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
> > > > index 48126ae4cd13..28be39a703c9 100644
> > > > --- a/tools/perf/util/parse-events.y
> > > > +++ b/tools/perf/util/parse-events.y
> > > > @@ -104,7 +104,8 @@ static void inc_group_count(struct list_head *list,
> > > > struct list_head *head;
> > > > struct parse_events_term *term;
> > > > struct tracepoint_name {
> > > > - char *sys;
> > > > + char *sys1;
> > > > + char *sys2;
> > > > char *event;
> > > > } tracepoint_name;
> > > > struct parse_events_array array;
> > > > @@ -425,9 +426,19 @@ tracepoint_name opt_event_config
> > > > if (error)
> > > > error->idx = @1.first_column;
> > > >
> > > > - if (parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event,
> > > > - error, $2))
> > > > - return -1;
> > > > + if ($1.sys2) {
> > > > + char sys_name[128];
> > > > + snprintf(&sys_name, sizeof(sys_name), "%s-%s",
> > > > + $1.sys1, $1.sys2);
> > > > + if (parse_events_add_tracepoint(list, &parse_state->idx,
> > > > + sys_name, $1.event,
> > > > + error, $2))
> > > > + return -1;
> > > > + } else
> > > > + if (parse_events_add_tracepoint(list, &parse_state->idx,
> > > > + $1.sys1, $1.event,
> > > > + error, $2))
> > > > + return -1;
> > >
> > > nice catch, please enclose all multiline condition legs with {}
> > >
> > > other than that
> > >
> > > Acked-by: Jiri Olsa <jolsa@...nel.org>
> >
> > Ian, this one isn't applying to my perf/core branch, can you please
> > address Jiri's comment and resubmit?
> >
> > - arnaldo
--
- Arnaldo
Powered by blists - more mailing lists