From: sashiko-bot@kernel.org
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 05/13] perf dso: Set error code when open() fails on uncompressed fallback path
Date: Fri, 12 Jun 2026 22:40:18 +0000 [thread overview]
Message-ID: <20260612224019.1EFD61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260612222413.40791-6-acme@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Negative custom error codes leak into standard errno and cause __open_dso() to compute a positive fake file descriptor.
--
commit d095129ae47ce61267962a75bfe2602fe1eafe44
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf dso: Set error code when open() fails on uncompressed fallback path
This commit sets the error code when open() fails on the uncompressed
fallback path in filename__decompress(). It ensures the caller chain
correctly reads the populated errno instead of a stale or zero value.
> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index 511921bd901d8..1a2fc6d18da74 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
> @@ -344,9 +344,12 @@ int filename__decompress(const char *name, char *pathname,
> * descriptor to the uncompressed file.
> */
> if (!compressions[comp].is_compressed(name)) {
> + fd = open(name, O_RDONLY | O_CLOEXEC);
> + if (fd < 0)
> + *err = errno;
> if (pathname && len > 0)
> pathname[0] = '\0';
> - return open(name, O_RDONLY | O_CLOEXEC);
> + return fd;
> }
>
> fd = mkostemp(tmpbuf, O_CLOEXEC);
[Severity: High]
This isn't a bug introduced by this patch, but the commit message mentions
matching the error handling on the compressed path. Does that compressed
path have an issue where negative custom error codes leak into standard
errno?
If filename__decompress() sets *err to the custom enum value
DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE (which is negative),
dso__get_filename() assigns this directly into standard errno:
tools/perf/util/dso.c:dso__get_filename() {
...
errno = *dso__load_errno(dso);
...
}
Then __open_dso() handles the failure by calculating fd = -errno:
tools/perf/util/dso.c:__open_dso() {
...
fd = -errno;
...
}
Could this double-negate the custom error code into a positive file
descriptor value (like 9996)?
If open_dso() then incorrectly believes it successfully opened the DSO
because fd >= 0, could it cache this as the active file descriptor?
This might cause close_data_fd() to later close an arbitrary file
descriptor used by another subsystem when perf cleans up.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260612222413.40791-1-acme@kernel.org?part=5
next prev parent reply other threads:[~2026-06-12 22:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 22:23 [PATCHES v2 00/13] perf tools: Fix pre-existing bugs in symbols, dso, bpf, sched, c2c, hwmon, and cs-etm Arnaldo Carvalho de Melo
2026-06-12 22:24 ` [PATCH 01/13] perf symbols: Fix bswap copy-paste error for 32-bit ELF p_filesz Arnaldo Carvalho de Melo
2026-06-12 22:24 ` [PATCH 02/13] perf symbols: Validate p_filesz before use in filename__read_build_id() Arnaldo Carvalho de Melo
2026-06-12 22:24 ` [PATCH 03/13] perf symbols: Break infinite loop on zero-filled notes in sysfs__read_build_id() Arnaldo Carvalho de Melo
2026-06-12 22:24 ` [PATCH 04/13] perf dso: Fix heap overflow in dso__get_filename() on decompressed path Arnaldo Carvalho de Melo
2026-06-12 22:24 ` [PATCH 05/13] perf dso: Set error code when open() fails on uncompressed fallback path Arnaldo Carvalho de Melo
2026-06-12 22:40 ` sashiko-bot [this message]
2026-06-12 22:24 ` [PATCH 06/13] perf tools: Use snprintf() for root_dir path construction Arnaldo Carvalho de Melo
2026-06-13 0:37 ` sashiko-bot
2026-06-12 22:24 ` [PATCH 07/13] perf hwmon: Fix fd check to accept fd 0 in hwmon_pmu__describe_items() Arnaldo Carvalho de Melo
2026-06-12 22:24 ` [PATCH 08/13] perf sched: Replace (void*)1 sentinel with proper runtime allocation Arnaldo Carvalho de Melo
2026-06-12 22:24 ` [PATCH 09/13] perf bpf: Validate func_info_rec_size and sub_id in synthesize_bpf_prog_name() Arnaldo Carvalho de Melo
2026-06-12 22:44 ` sashiko-bot
2026-06-12 22:24 ` [PATCH 10/13] perf bpf: Reject oversized BPF metadata events that truncate header.size Arnaldo Carvalho de Melo
2026-06-12 22:24 ` [PATCH 11/13] perf bpf: Bounds-check array offsets in bpil_offs_to_addr() Arnaldo Carvalho de Melo
2026-06-12 22:24 ` [PATCH 12/13] perf c2c: Free format list entries when releasing c2c hist entries Arnaldo Carvalho de Melo
2026-06-12 22:24 ` [PATCH 13/13] perf cs-etm: Reject CPU IDs that would overflow signed comparison Arnaldo Carvalho de Melo
2026-06-12 22:51 ` sashiko-bot
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=20260612224019.1EFD61F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=acme@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