All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] perf parse-events: fix memory leaks found on parse_events
@ 2020-03-19  2:31 Ian Rogers
  2020-03-19  2:31 ` [PATCH v2 2/2] libperf evlist: fix memory leaks Ian Rogers
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Ian Rogers @ 2020-03-19  2:31 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Andi Kleen, Adrian Hunter, Leo Yan, linux-kernel,
	clang-built-linux
  Cc: Stephane Eranian, Ian Rogers

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);
 			free(pos);
 		}
 		return -EINVAL;
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);
 }
@@ -326,6 +326,7 @@ PE_NAME opt_pmu_config
 	}
 	parse_events_terms__delete($2);
 	parse_events_terms__delete(orig_terms);
+	free(pattern);
 	free($1);
 	$$ = list;
 #undef CLEANUP_YYABORT
-- 
2.25.1.696.g5e7596f4ac-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/2] libperf evlist: fix memory leaks
  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 ` 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
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 12+ messages in thread
From: Ian Rogers @ 2020-03-19  2:31 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Andi Kleen, Adrian Hunter, Leo Yan, linux-kernel,
	clang-built-linux
  Cc: Stephane Eranian, Ian Rogers

Memory leaks found by applying LLVM's libfuzzer on the tools/perf
parse_events function.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/lib/perf/evlist.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c
index 5b9f2ca50591..6485d1438f75 100644
--- a/tools/lib/perf/evlist.c
+++ b/tools/lib/perf/evlist.c
@@ -125,8 +125,10 @@ static void perf_evlist__purge(struct perf_evlist *evlist)
 void perf_evlist__exit(struct perf_evlist *evlist)
 {
 	perf_cpu_map__put(evlist->cpus);
+	perf_cpu_map__put(evlist->all_cpus);
 	perf_thread_map__put(evlist->threads);
 	evlist->cpus = NULL;
+	evlist->all_cpus = NULL;
 	evlist->threads = NULL;
 	fdarray__exit(&evlist->pollfd);
 }
-- 
2.25.1.696.g5e7596f4ac-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/2] perf parse-events: fix memory leaks found on parse_events
  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 10:59 ` Jiri Olsa
  2020-04-29 17:43   ` Ian Rogers
  2020-04-29 17:54 ` Arnaldo Carvalho de Melo
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Jiri Olsa @ 2020-03-23 10:59 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Namhyung Kim, Andi Kleen,
	Adrian Hunter, Leo Yan, linux-kernel, clang-built-linux,
	Stephane Eranian

On Wed, Mar 18, 2020 at 07:31:00PM -0700, Ian Rogers wrote:
> Memory leaks found by applying LLVM's libfuzzer on the parse_events
> function.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>

Acked-by: Jiri Olsa <jolsa@redhat.com>

thanks,
jirka

> ---
>  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);
>  			free(pos);
>  		}
>  		return -EINVAL;
> 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);
>  }
> @@ -326,6 +326,7 @@ PE_NAME opt_pmu_config
>  	}
>  	parse_events_terms__delete($2);
>  	parse_events_terms__delete(orig_terms);
> +	free(pattern);
>  	free($1);
>  	$$ = list;
>  #undef CLEANUP_YYABORT
> -- 
> 2.25.1.696.g5e7596f4ac-goog
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] libperf evlist: fix memory leaks
  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
  1 sibling, 0 replies; 12+ messages in thread
From: Jiri Olsa @ 2020-03-23 11:01 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Namhyung Kim, Andi Kleen,
	Adrian Hunter, Leo Yan, linux-kernel, clang-built-linux,
	Stephane Eranian

On Wed, Mar 18, 2020 at 07:31:01PM -0700, Ian Rogers wrote:
> Memory leaks found by applying LLVM's libfuzzer on the tools/perf
> parse_events function.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>

Arnaldo,
could you plz pull first:
  https://lore.kernel.org/lkml/1583665157-349023-1-git-send-email-zhe.he@windriver.com/

and then merge in this one? 

thanks,
jirka

Acked-by: Jiri Olsa <jolsa@redhat.com>

> ---
>  tools/lib/perf/evlist.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c
> index 5b9f2ca50591..6485d1438f75 100644
> --- a/tools/lib/perf/evlist.c
> +++ b/tools/lib/perf/evlist.c
> @@ -125,8 +125,10 @@ static void perf_evlist__purge(struct perf_evlist *evlist)
>  void perf_evlist__exit(struct perf_evlist *evlist)
>  {
>  	perf_cpu_map__put(evlist->cpus);
> +	perf_cpu_map__put(evlist->all_cpus);
>  	perf_thread_map__put(evlist->threads);
>  	evlist->cpus = NULL;
> +	evlist->all_cpus = NULL;
>  	evlist->threads = NULL;
>  	fdarray__exit(&evlist->pollfd);
>  }
> -- 
> 2.25.1.696.g5e7596f4ac-goog
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/2] perf parse-events: fix memory leaks found on parse_events
  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
  0 siblings, 0 replies; 12+ messages in thread
From: Ian Rogers @ 2020-04-29 17:43 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Namhyung Kim, Andi Kleen,
	Adrian Hunter, Leo Yan, LKML, clang-built-linux,
	Stephane Eranian

On Mon, Mar 23, 2020 at 3:59 AM Jiri Olsa <jolsa@redhat.com> wrote:
>
> On Wed, Mar 18, 2020 at 07:31:00PM -0700, Ian Rogers wrote:
> > Memory leaks found by applying LLVM's libfuzzer on the parse_events
> > function.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
>
> Acked-by: Jiri Olsa <jolsa@redhat.com>
>
> thanks,
> jirka

Ping.

> > ---
> >  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);
> >                       free(pos);
> >               }
> >               return -EINVAL;
> > 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);
> >  }
> > @@ -326,6 +326,7 @@ PE_NAME opt_pmu_config
> >       }
> >       parse_events_terms__delete($2);
> >       parse_events_terms__delete(orig_terms);
> > +     free(pattern);
> >       free($1);
> >       $$ = list;
> >  #undef CLEANUP_YYABORT
> > --
> > 2.25.1.696.g5e7596f4ac-goog
> >
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/2] perf parse-events: fix memory leaks found on parse_events
  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 10:59 ` [PATCH v2 1/2] perf parse-events: fix memory leaks found on parse_events Jiri Olsa
@ 2020-04-29 17:54 ` Arnaldo Carvalho de Melo
  2020-04-30 21:39   ` Ian Rogers
  2020-05-08 13:05 ` [tip: perf/core] perf parse-events: Fix another memory leaks found on parse_events() tip-bot2 for Ian Rogers
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-04-29 17:54 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Andi Kleen, Adrian Hunter, Leo Yan,
	linux-kernel, clang-built-linux, Stephane Eranian

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,

- Arnaldo

> @@ -326,6 +326,7 @@ PE_NAME opt_pmu_config
>  	}
>  	parse_events_terms__delete($2);
>  	parse_events_terms__delete(orig_terms);
> +	free(pattern);
>  	free($1);
>  	$$ = list;
>  #undef CLEANUP_YYABORT
> -- 
> 2.25.1.696.g5e7596f4ac-goog
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/2] perf parse-events: fix memory leaks found on parse_events
  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
  0 siblings, 1 reply; 12+ messages in thread
From: Ian Rogers @ 2020-04-30 21:39 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Andi Kleen, Adrian Hunter, Leo Yan,
	LKML, clang-built-linux, Stephane Eranian

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.

Ian

> Thanks,
>
> - Arnaldo
>
> > @@ -326,6 +326,7 @@ PE_NAME opt_pmu_config
> >       }
> >       parse_events_terms__delete($2);
> >       parse_events_terms__delete(orig_terms);
> > +     free(pattern);
> >       free($1);
> >       $$ = list;
> >  #undef CLEANUP_YYABORT
> > --
> > 2.25.1.696.g5e7596f4ac-goog
> >
>
> --
>
> - Arnaldo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/2] perf parse-events: fix memory leaks found on parse_events
  2020-04-30 21:39   ` Ian Rogers
@ 2020-05-02 15:11     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-05-02 15:11 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Andi Kleen, Adrian Hunter, Leo Yan, LKML, clang-built-linux,
	Stephane Eranian

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [tip: perf/core] perf parse-events: Fix another memory leaks found on parse_events()
  2020-03-19  2:31 [PATCH v2 1/2] perf parse-events: fix memory leaks found on parse_events Ian Rogers
                   ` (2 preceding siblings ...)
  2020-04-29 17:54 ` Arnaldo Carvalho de Melo
@ 2020-05-08 13:05 ` 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
  5 siblings, 0 replies; 12+ messages in thread
From: tip-bot2 for Ian Rogers @ 2020-05-08 13:05 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ian Rogers, Jiri Olsa, Adrian Hunter, Alexander Shishkin,
	Andi Kleen, Leo Yan, Mark Rutland, Namhyung Kim, Peter Zijlstra,
	Stephane Eranian, clang-built-linux, Arnaldo Carvalho de Melo,
	x86, LKML

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     ba08829aace99b23da31b9b71d8ed5d40a44ed49
Gitweb:        https://git.kernel.org/tip/ba08829aace99b23da31b9b71d8ed5d40a44ed49
Author:        Ian Rogers <irogers@google.com>
AuthorDate:    Wed, 18 Mar 2020 19:31:00 -07:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Tue, 05 May 2020 16:35:29 -03:00

perf parse-events: Fix another memory leaks found on parse_events()

Fix another memory leak found by applying LLVM's libfuzzer on parse_events().

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: clang-built-linux@googlegroups.com
Link: http://lore.kernel.org/lkml/20200319023101.82458-1-irogers@google.com
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/parse-events.y | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 6ece67e..c4ca932 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -326,6 +326,7 @@ PE_NAME opt_pmu_config
 	}
 	parse_events_terms__delete($2);
 	parse_events_terms__delete(orig_terms);
+	free(pattern);
 	free($1);
 	$$ = list;
 #undef CLEANUP_YYABORT

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [tip: perf/core] libperf evlist: Fix a refcount leak
  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-bot2 for Ian Rogers
  1 sibling, 0 replies; 12+ messages in thread
From: tip-bot2 for Ian Rogers @ 2020-05-08 13:05 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ian Rogers, Adrian Hunter, Alexander Shishkin, Andi Kleen,
	Jiri Olsa, Leo Yan, Mark Rutland, Namhyung Kim, Peter Zijlstra,
	Stephane Eranian, clang-built-linux, Arnaldo Carvalho de Melo,
	x86, LKML

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     4599d292128d89e4cf866a0ea9a9b047a2de8418
Gitweb:        https://git.kernel.org/tip/4599d292128d89e4cf866a0ea9a9b047a2de8418
Author:        Ian Rogers <irogers@google.com>
AuthorDate:    Wed, 18 Mar 2020 19:31:01 -07:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Tue, 05 May 2020 16:35:29 -03:00

libperf evlist: Fix a refcount leak

Memory leaks found by applying LLVM's libfuzzer on the tools/perf
parse_events function.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: clang-built-linux@googlegroups.com
Link: http://lore.kernel.org/lkml/20200319023101.82458-2-irogers@google.com
[ Did a minor adjustment due to some other previous patch having already set evlist->all_cpus to NULL at perf_evlist__exit() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/perf/evlist.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c
index c481b62..6a875a0 100644
--- a/tools/lib/perf/evlist.c
+++ b/tools/lib/perf/evlist.c
@@ -123,6 +123,7 @@ static void perf_evlist__purge(struct perf_evlist *evlist)
 void perf_evlist__exit(struct perf_evlist *evlist)
 {
 	perf_cpu_map__put(evlist->cpus);
+	perf_cpu_map__put(evlist->all_cpus);
 	perf_thread_map__put(evlist->threads);
 	evlist->cpus = NULL;
 	evlist->all_cpus = NULL;

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [tip: perf/core] perf parse-events: Fix memory leaks found on parse_events
  2020-03-19  2:31 [PATCH v2 1/2] perf parse-events: fix memory leaks found on parse_events Ian Rogers
                   ` (4 preceding siblings ...)
  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
  5 siblings, 0 replies; 12+ messages in thread
From: tip-bot2 for Ian Rogers @ 2020-05-08 13:05 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ian Rogers, Adrian Hunter, Jiri Olsa, Alexander Shishkin,
	Andi Kleen, Leo Yan, Mark Rutland, Namhyung Kim, Peter Zijlstra,
	Stephane Eranian, clang-built-linux, Arnaldo Carvalho de Melo,
	x86, LKML

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     672f707ef55f0a56b9bb67c3cfbdcab85c233796
Gitweb:        https://git.kernel.org/tip/672f707ef55f0a56b9bb67c3cfbdcab85c233796
Author:        Ian Rogers <irogers@google.com>
AuthorDate:    Wed, 18 Mar 2020 19:31:00 -07:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Tue, 05 May 2020 16:35:29 -03:00

perf parse-events: Fix memory leaks found on parse_events

free_list_evsel() deals with tools/perf/ evsels, not with libperf
perf_evsels, use the right destructor and avoid a leak, as
evsel__delete() will delete something perf_evsel__delete() doesn't.

Signed-off-by: Ian Rogers <irogers@google.com>

Cc: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: clang-built-linux@googlegroups.com
Link: http://lore.kernel.org/lkml/20200319023101.82458-1-irogers@google.com
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/parse-events.y | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index e879eb2..6ece67e 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);
 }

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [tip: perf/core] perf parse-events: Fix memory leaks found on parse_events
  2020-03-19  2:31 [PATCH v2 1/2] perf parse-events: fix memory leaks found on parse_events Ian Rogers
                   ` (3 preceding siblings ...)
  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-bot2 for Ian Rogers
  2020-05-08 13:05 ` tip-bot2 for Ian Rogers
  5 siblings, 0 replies; 12+ messages in thread
From: tip-bot2 for Ian Rogers @ 2020-05-08 13:05 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ian Rogers, Jiri Olsa, Adrian Hunter, Alexander Shishkin,
	Andi Kleen, Leo Yan, Mark Rutland, Namhyung Kim, Peter Zijlstra,
	Stephane Eranian, clang-built-linux, Arnaldo Carvalho de Melo,
	x86, LKML

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     e8dfb81838b14f82521968343884665b996646ef
Gitweb:        https://git.kernel.org/tip/e8dfb81838b14f82521968343884665b996646ef
Author:        Ian Rogers <irogers@google.com>
AuthorDate:    Wed, 18 Mar 2020 19:31:00 -07:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Tue, 05 May 2020 16:35:29 -03:00

perf parse-events: Fix memory leaks found on parse_events

Fix a memory leak found by applying LLVM's libfuzzer on parse_events().

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: clang-built-linux@googlegroups.com
Link: http://lore.kernel.org/lkml/20200319023101.82458-1-irogers@google.com
[ split from a larger patch, use zfree() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/parse-events.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 5795f3a..6dc9e57 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1482,6 +1482,7 @@ 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);
+			zfree(&pos->val.str);
 			free(pos);
 		}
 		return -EINVAL;

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-05-08 13:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.