From: sashiko-bot@kernel.org
To: "Namhyung Kim" <namhyung@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v3 08/10] perf symbol: Do not set binary type from symtab type
Date: Mon, 12 Oct 2026 05:38:26 +0000 [thread overview]
Message-ID: <sashiko-outbox-167681@kernel.org> (raw)
In-Reply-To: <20261012052601.13920-9-namhyung@kernel.org>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] perf/dso: out-of-bounds access in close_first_dso() on empty list
- [Medium] perf/dso: deadlock in __dso__find_binary_type() during EMFILE retry
- [Medium] perf: stale errno causes false failure in dso__find_binary_type_locked()
--
commit bda2b4581480880eb2e75b857a614dacf9c33795
Author: Namhyung Kim <namhyung@kernel.org>
perf symbol: Do not set binary type from symtab type
The DSO binary type is intended to access binary data, while the symtab
type is for the symbol table. This commit separates their tracking by
leaving the binary type info intact and only updating it when actually
opening the DSO.
> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index 851b39c63ec86..a8e531766f1b5 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
> @@ -1485,9 +1485,10 @@ uint16_t dso__e_machine_endian(struct dso *dso, struct machine *machine, uint32_
> bool *is_big_endian)
> {
> uint16_t e_machine = EM_NONE;
> + enum dso_binary_type dbt = dso__find_binary_type(dso);
[Severity: Medium]
This new call to dso__find_binary_type() can expose a potential deadlock.
If dso__find_binary_type_locked() returns -1 due to an open file limit,
__dso__find_binary_type() acquires dso__data_open_lock() but does not release
it before jumping back:
tools/perf/util/dso.c:__dso__find_binary_type() {
...
if (ret == -1 && retry++ < FIND_MAX_RETRY) {
if (needs_open_lock)
mutex_lock(dso__data_open_lock());
close_first_dso();
goto again;
}
...
}
Could this cause a double-lock deadlock on dso__data_open_lock() if
ret == -1 happens again on the next iteration?
[Severity: High]
When __dso__find_binary_type() encounters EMFILE, it unconditionally calls
close_first_dso():
tools/perf/util/dso.c:__dso__find_binary_type() {
...
close_first_dso();
...
}
Does close_first_dso() extract the first entry from the dso__data_open list
without verifying if the list is actually populated?
tools/perf/util/dso.c:close_first_dso() {
...
dso_data = list_first_entry(&dso__data_open, struct dso_data, open_entry);
...
}
If the list is empty, couldn't this yield an invalid pointer and lead to
out-of-bounds memory corruption when closing the fd?
[Severity: Medium]
Inside dso__find_binary_type_locked(), it appears we read errno unconditionally
when filename__has_section() returns false:
tools/perf/util/dso.c:dso__find_binary_type_locked() {
...
found = filename__has_section(path, ".text");
if (!found)
saved_errno = errno;
dso__put_filename(dso, path, decomp);
if (found)
return dso__binary_type(dso);
else if (saved_errno == EMFILE)
goto open_err;
...
}
Since a false return legitimately occurs when the .text section is missing
(without updating errno), could a stale EMFILE value be erroneously captured
here and cause false failures?
> int fd;
>
> - switch (dso__binary_type(dso)) {
> + switch (dbt) {
> case DSO_BINARY_TYPE__KALLSYMS:
> case DSO_BINARY_TYPE__GUEST_KALLSYMS:
> case DSO_BINARY_TYPE__VMLINUX:
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012052601.13920-1-namhyung@kernel.org?part=8
next prev parent reply other threads:[~2026-10-12 5:38 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 5:25 [PATCH v3 00/10] perf symbol: Properly set DSO binary/symtab types Namhyung Kim
2026-10-12 5:25 ` [PATCH v3 01/10] perf tools: Remove redundant dso data init Namhyung Kim
2026-10-12 5:30 ` sashiko-bot
2026-10-12 5:25 ` [PATCH v3 02/10] perf tools: Try linked debug files for DSO debug info Namhyung Kim
2026-10-12 5:35 ` sashiko-bot
2026-10-12 5:25 ` [PATCH v3 03/10] perf symbol: Update symtab type of vmlinux from build-id cache Namhyung Kim
2026-10-12 5:38 ` sashiko-bot
2026-10-12 5:25 ` [PATCH v3 04/10] perf symbol: Set binary/symtab type for split kallsyms Namhyung Kim
2026-10-12 5:33 ` sashiko-bot
2026-10-12 5:25 ` [PATCH v3 05/10] perf symbol: Get rid of machine_or_dso_e_machine() Namhyung Kim
2026-10-12 5:44 ` sashiko-bot
2026-10-12 5:25 ` [PATCH v3 06/10] perf tools: Factor out dso__find_binary_type() Namhyung Kim
2026-10-12 5:38 ` sashiko-bot
2026-10-12 19:50 ` Namhyung Kim
2026-10-12 21:37 ` Ian Rogers
2026-10-12 5:25 ` [PATCH v3 07/10] perf symbol: Set binary type for JIT map DSOs Namhyung Kim
2026-10-12 5:34 ` sashiko-bot
2026-10-12 5:25 ` [PATCH v3 08/10] perf symbol: Do not set binary type from symtab type Namhyung Kim
2026-10-12 5:38 ` sashiko-bot [this message]
2026-10-12 5:26 ` [PATCH v3 09/10] perf annotate: Simplify symbol__disassemble() with dso binary_type Namhyung Kim
2026-10-12 5:36 ` sashiko-bot
2026-10-12 5:26 ` [PATCH v3 10/10] perf test: Fix dso data tests Namhyung Kim
2026-10-12 5:37 ` sashiko-bot
2026-10-12 21:41 ` [PATCH v3 00/10] perf symbol: Properly set DSO binary/symtab types Ian Rogers
2026-10-12 23:07 ` 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=sashiko-outbox-167681@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@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