From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 1/3] perf libdw: Fix Dwfl discovery with split files
Date: Wed, 16 Sep 2026 06:52:05 +0000 [thread overview]
Message-ID: <20260916065206.0F5F51F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916063545.3103314-2-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] perf libbfd: TOCTOU race populating cache with stale dso_name
--
commit 6a983b5d3f6eb6250b40233e72f23d9a6454ca97
Author: Ian Rogers <irogers@google.com>
perf libdw: Fix Dwfl discovery with split files
This commit updates Dwfl initialization to use the symsrc filename when
available, falling back to the long name. It drops the cached Dwfl and
addr2line cache when the symsrc filename is set, using the dso lock to
safely handle concurrent teardown and access.
> diff --git a/tools/perf/util/libbfd.c b/tools/perf/util/libbfd.c
> --- a/tools/perf/util/libbfd.c
> +++ b/tools/perf/util/libbfd.c
> @@ -226,7 +226,10 @@ int libbfd__addr2line(const char *dso_name, u64 addr,
> struct symbol *sym)
> {
> int ret = 0;
> - struct a2l_data *a2l = dso__a2l(dso);
> + struct a2l_data *a2l;
> +
> + mutex_lock(dso__lock(dso));
> + a2l = dso__a2l(dso);
>
> if (!a2l) {
> a2l = addr2line_init(dso_name);
> dso__set_a2l(dso, a2l);
> }
[Severity: Medium]
Is there a Time-of-Check-to-Time-of-Use race here when populating the a2l
cache?
In __get_srcline(), dso_name is fetched before the lock is acquired in
libbfd__addr2line():
tools/perf/util/srcline.c:__get_srcline() {
...
dso_name = srcline_dso_name(dso);
if (dso_name == NULL)
goto out_err;
if (!addr2line(dso_name, addr, &file, &line, dso, ...
}
If another thread calls dso__set_symsrc_filename(), which updates the
debuginfo file and clears the cache, before libbfd__addr2line() acquires
its mutex:
Thread 1
dso__set_symsrc_filename()
dso__free_a2l(dso);
Thread 2 would see a NULL cache in libbfd__addr2line() and populate it using
the stale dso_name argument:
if (!a2l) {
a2l = addr2line_init(dso_name);
dso__set_a2l(dso, a2l);
}
Could this permanently poison the cache with a BFD instance for a file
lacking debuginfo by not verifying it against the current symsrc_filename
under the lock?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260916063545.3103314-1-irogers@google.com?part=1
next prev parent reply other threads:[~2026-09-16 6:52 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 17:07 [PATCH v1 1/2] perf libdw: Fix Dwfl discovery with split files Ian Rogers
2026-09-14 17:07 ` [PATCH v1 2/2] perf dso: Separate libbfd and cmd addr2line caches to fix confusion Ian Rogers
2026-09-14 17:24 ` sashiko-bot
2026-09-14 17:30 ` [PATCH v1 1/2] perf libdw: Fix Dwfl discovery with split files sashiko-bot
2026-09-16 6:35 ` [PATCH v2 0/3] perf srcline: Fix addr2line cache and fallback bugs Ian Rogers
2026-09-16 6:35 ` [PATCH v2 1/3] perf libdw: Fix Dwfl discovery with split files Ian Rogers
2026-09-16 6:52 ` sashiko-bot [this message]
2026-09-16 6:35 ` [PATCH v2 2/3] perf dso: Separate libbfd and cmd addr2line caches to fix confusion Ian Rogers
2026-09-16 6:47 ` sashiko-bot
2026-09-16 6:35 ` [PATCH v2 3/3] perf libbfd: Report success when an address is found Ian Rogers
2026-09-16 6:47 ` sashiko-bot
2026-09-16 23:43 ` [PATCH v3 0/3] perf srcline: Fix addr2line cache and fallback bugs Ian Rogers
2026-09-16 23:44 ` [PATCH v3 1/3] perf libdw: Fix Dwfl discovery with split files Ian Rogers
2026-09-17 0:03 ` sashiko-bot
2026-09-16 23:44 ` [PATCH v3 2/3] perf dso: Separate libbfd and cmd addr2line caches to fix confusion Ian Rogers
2026-09-16 23:54 ` sashiko-bot
2026-09-16 23:44 ` [PATCH v3 3/3] perf libbfd: Report success when an address is found Ian Rogers
2026-09-16 23:54 ` sashiko-bot
2026-09-17 5:04 ` [PATCH v4 0/3] perf srcline: Fix addr2line cache and fallback bugs Ian Rogers
2026-09-17 5:04 ` [PATCH v4 1/3] perf libdw: Fix Dwfl discovery with split files Ian Rogers
2026-09-17 5:20 ` sashiko-bot
2026-09-17 5:04 ` [PATCH v4 2/3] perf dso: Separate libbfd and cmd addr2line caches to fix confusion Ian Rogers
2026-09-17 5:12 ` sashiko-bot
2026-09-17 5:04 ` [PATCH v4 3/3] perf libbfd: Report success when an address is found Ian Rogers
2026-09-17 5:16 ` sashiko-bot
2026-09-18 20:25 ` [PATCH v3 0/3] perf srcline: Fix addr2line cache and fallback bugs Arnaldo Carvalho de Melo
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=20260916065206.0F5F51F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=irogers@google.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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