From: Namhyung Kim <namhyung@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 3/3] perf symbol: Set dso symtab type for libbfd
Date: Sat, 10 Oct 2026 12:02:42 -0700 [thread overview]
Message-ID: <asqL0l19OLRbQ6VG@z2> (raw)
In-Reply-To: <sashiko-outbox-166825@kernel.org>
On Sat, Oct 10, 2026 at 06:34:40PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] perf: double-free and state confusion in libbfd fallback path
> --
>
> commit 8791c82124897f35132a0fe029d993b2dcd4a6bc
> Author: Namhyung Kim <namhyung@kernel.org>
>
> perf symbol: Set dso symtab type for libbfd
>
> It missed to set the dso symtab type when the symbols are loaded by
> libbfd. When it happens both syms_ss and runtime_ss may not be set
> and won't call dso__load_sym().
>
> > diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> > index 5e63c3477570c..debd0a66f9669 100644
> > --- a/tools/perf/util/symbol.c
> > +++ b/tools/perf/util/symbol.c
> > @@ -1929,6 +1929,7 @@ int dso__load(struct dso *dso, struct map *map)
> > symsrc__destroy(syms_ss);
> > syms_ss = NULL;
> > }
> > + dso__set_symtab_type(dso, symtab_type);
> > ret = 1;
> > break;
> > }
>
> [Severity: High]
> When dso__load_bfd_symbols() succeeds and sets ret = 1, this explicit
> destruction of syms_ss does not remove the struct from the ss_ array because
> ss_pos remains unmodified.
>
> Does this lead to a double-free later in the cleanup loop?
>
> tools/perf/util/symbol.c:dso__load() {
> ...
> for (; ss_pos > 0; ss_pos--)
> symsrc__destroy(&ss_[ss_pos - 1]);
> ...
> }
>
> Additionally, since runtime_ss is not cleared here, can execution incorrectly
> fall through to dso__load_sym() and overwrite the successful ret = 1 value
> from libbfd?
I don't expect it sets runtime_ss, but I'll make sure it's cleared.
Thanks,
Namhyung
>
> tools/perf/util/symbol.c:dso__load() {
> ...
> if (runtime_ss && !syms_ss) {
> syms_ss = runtime_ss;
> }
>
> /* We'll have to hope for the best */
> if (!runtime_ss && syms_ss)
> runtime_ss = syms_ss;
>
> if (syms_ss)
> ret = dso__load_sym(dso, map, syms_ss, runtime_ss, kmod);
> ...
> }
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261010182439.9732-1-namhyung@kernel.org?part=3
next prev parent reply other threads:[~2026-10-10 19:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 18:24 [PATCH v2 1/3] perf symbol: Fix symbol loading from libbfd Namhyung Kim
2026-10-10 18:24 ` [PATCH v2 2/3] perf symbol: Add missing symsrc__destroy() for libbfd Namhyung Kim
2026-10-10 18:34 ` sashiko-bot
2026-10-10 19:01 ` Namhyung Kim
2026-10-10 18:24 ` [PATCH v2 3/3] perf symbol: Set dso symtab type " Namhyung Kim
2026-10-10 18:34 ` sashiko-bot
2026-10-10 19:02 ` Namhyung Kim [this message]
2026-10-10 18:36 ` [PATCH v2 1/3] perf symbol: Fix symbol loading from libbfd sashiko-bot
2026-10-10 19:00 ` Namhyung Kim
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=asqL0l19OLRbQ6VG@z2 \
--to=namhyung@kernel.org \
--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