public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Ian Rogers <irogers@google.com>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Andi Kleen <ak@linux.intel.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Leo Yan <leo.yan@linaro.org>, LKML <linux-kernel@vger.kernel.org>,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH v2 1/2] perf parse-events: fix memory leaks found on parse_events
Date: Sat, 2 May 2020 12:11:48 -0300	[thread overview]
Message-ID: <20200502151148.GA5377@kernel.org> (raw)
In-Reply-To: <CAP-5=fWTAbyOXr5GghrbvfkaZ6EzH7GNDJiiDJkFqeF5mPgDeA@mail.gmail.com>

Em Thu, Apr 30, 2020 at 02:39:14PM -0700, Ian Rogers escreveu:
> On Wed, Apr 29, 2020 at 10:54 AM Arnaldo Carvalho de Melo
> <arnaldo.melo@gmail.com> wrote:
> >
> > Em Wed, Mar 18, 2020 at 07:31:00PM -0700, Ian Rogers escreveu:
> > > Memory leaks found by applying LLVM's libfuzzer on the parse_events
> > > function.
> > >
> > > Signed-off-by: Ian Rogers <irogers@google.com>
> > > ---
> > >  tools/perf/util/parse-events.c | 2 ++
> > >  tools/perf/util/parse-events.y | 3 ++-
> > >  2 files changed, 4 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> > > index 593b6b03785d..1e0bec5c0846 100644
> > > --- a/tools/perf/util/parse-events.c
> > > +++ b/tools/perf/util/parse-events.c
> > > @@ -1482,6 +1482,8 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
> > >
> > >               list_for_each_entry_safe(pos, tmp, &config_terms, list) {
> > >                       list_del_init(&pos->list);
> > > +                     if (pos->free_str)
> > > +                             free(pos->val.str);
> >
> > I'm applying it but only after changing it to zfree(&pos->free_str), to
> > make sure that any othe rcode that may still hold a pointer to pos will
> > see a NULL in ->free_str and crash sooner rather than later.
> >
> > >                       free(pos);
> > >               }
> > >               return -EINVAL;
> >
> > And the following should be in a different patch
> >
> > > diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
> > > index 94f8bcd83582..8212cc771667 100644
> > > --- a/tools/perf/util/parse-events.y
> > > +++ b/tools/perf/util/parse-events.y
> > > @@ -44,7 +44,7 @@ static void free_list_evsel(struct list_head* list_evsel)
> > >
> > >       list_for_each_entry_safe(evsel, tmp, list_evsel, core.node) {
> > >               list_del_init(&evsel->core.node);
> > > -             perf_evsel__delete(evsel);
> > > +             evsel__delete(evsel);
> > >       }
> > >       free(list_evsel);
> > >  }
> >
> > And this one in another, I'll fix this up, but please try in the future
> > to provide different patches for different fixes, so that if we
> > eventually find out that one of the unrelated fixes is wrong, then we
> > can revert the patch more easily with 'git revert' instead of having to
> > do a patch that reverts just part of the bigger hodge-podge patch.
> >
> > If you go and have a track record of doing this as piecemeal as
> > possible, I will in turn feel more confident of processing your patches
> > in a faster fashion ;-) :-)
> 
> Thanks, at some point I'd like to get libfuzzer with asan working for
> more than just me so that we don't backslide. It'd also make the
> reproductions easier to share.

If we can detect the presence of the needed components, libraries,
compiler with the right feature set, yeah, a 'perf test' built under
such environment surely would benefit from having further tests,

- Arnaldo

  reply	other threads:[~2020-05-02 15:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-19  2:31 [PATCH v2 1/2] perf parse-events: fix memory leaks found on parse_events Ian Rogers
2020-03-19  2:31 ` [PATCH v2 2/2] libperf evlist: fix memory leaks Ian Rogers
2020-03-23 11:01   ` Jiri Olsa
2020-05-08 13:05   ` [tip: perf/core] libperf evlist: Fix a refcount leak tip-bot2 for Ian Rogers
2020-03-23 10:59 ` [PATCH v2 1/2] perf parse-events: fix memory leaks found on parse_events Jiri Olsa
2020-04-29 17:43   ` Ian Rogers
2020-04-29 17:54 ` Arnaldo Carvalho de Melo
2020-04-30 21:39   ` Ian Rogers
2020-05-02 15:11     ` Arnaldo Carvalho de Melo [this message]
2020-05-08 13:05 ` [tip: perf/core] perf parse-events: Fix another memory leaks found on parse_events() tip-bot2 for Ian Rogers
2020-05-08 13:05 ` [tip: perf/core] perf parse-events: Fix memory leaks found on parse_events tip-bot2 for Ian Rogers
2020-05-08 13:05 ` tip-bot2 for Ian Rogers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200502151148.GA5377@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=jolsa@redhat.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox