From: Jiri Olsa <jolsa@redhat.com>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH] perf map: Fix namespace memory leak
Date: Sun, 28 Nov 2021 16:40:26 +0100 [thread overview]
Message-ID: <YaOi6pYqoc3boYX/@krava> (raw)
In-Reply-To: <20211118193714.2293728-1-irogers@google.com>
On Thu, Nov 18, 2021 at 11:37:14AM -0800, Ian Rogers wrote:
> This leak was happening reliably with test "Lookup mmap thread" with
> stack traces like:
>
> Direct leak of 5504 byte(s) in 172 object(s) allocated from:
> #0 0x7f4685e47987 in __interceptor_calloc
> #1 0x56063b974c2a in nsinfo__new util/namespaces.c:142
> #2 0x56063b9781ff in thread__new util/thread.c:70
> #3 0x56063b944953 in ____machine__findnew_thread util/machine.c:543
> #4 0x56063b944ac6 in __machine__findnew_thread util/machine.c:574
> #5 0x56063b944b36 in machine__findnew_thread util/machine.c:584
> #6 0x56063b94c892 in machine__process_fork_event util/machine.c:1954
> #7 0x56063b94cc1f in machine__process_event util/machine.c:2019
> #8 0x56063b894f18 in perf_event__process util/event.c:567
> #9 0x56063ba17951 in perf_tool__process_synth_event util/synthetic-events.c:65
> #10 0x56063ba19086 in perf_event__synthesize_fork util/synthetic-events.c:287
> #11 0x56063ba1c39d in __event__synthesize_thread util/synthetic-events.c:775
> #12 0x56063ba1cf6f in __perf_event__synthesize_threads util/synthetic-events.c:929
> #13 0x56063ba1d4ab in perf_event__synthesize_threads util/synthetic-events.c:1000
> #14 0x56063b821a3d in synth_all tests/mmap-thread-lookup.c:136
> #15 0x56063b821c86 in mmap_events tests/mmap-thread-lookup.c:174
> #16 0x56063b8221b7 in test__mmap_thread_lookup tests/mmap-thread-lookup.c:230
>
> The dso->nsinfo is overwritten, but without a nsinfo__put this can leak
> the overwritten nsinfo.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
nice catch!
Acked-by: Jiri Olsa <jolsa@redhat.com>
thanks,
jirka
> ---
> tools/perf/util/map.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
> index 8af693d9678c..ceed8f407bc0 100644
> --- a/tools/perf/util/map.c
> +++ b/tools/perf/util/map.c
> @@ -192,6 +192,7 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
> if (!(prot & PROT_EXEC))
> dso__set_loaded(dso);
> }
> + nsinfo__put(dso->nsinfo);
> dso->nsinfo = nsi;
>
> if (build_id__is_defined(bid))
> --
> 2.34.0.rc2.393.gf8c9666880-goog
>
next prev parent reply other threads:[~2021-11-28 15:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-18 19:37 [PATCH] perf map: Fix namespace memory leak Ian Rogers
2021-11-28 15:40 ` Jiri Olsa [this message]
2021-11-30 15:00 ` Arnaldo Carvalho de Melo
2021-11-30 17:20 ` Ian Rogers
2022-01-25 2:09 ` Ian Rogers
2022-01-25 4:48 ` Dmitry Vyukov
2022-01-25 7:01 ` Ian Rogers
2022-01-25 20:47 ` 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=YaOi6pYqoc3boYX/@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@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;
as well as URLs for NNTP newsgroup(s).