From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
James Clark <james.clark@linaro.org>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Clark Williams <williams@redhat.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Song Liu <song@kernel.org>
Subject: [PATCHES v2 0/5] perf DSO hardening series
Date: Tue, 11 Aug 2026 14:11:55 -0300 [thread overview]
Message-ID: <20260811171200.30096-1-acme@kernel.org> (raw)
Hi,
Please consider merging,
Five hardening fixes for the perf DSO data handling code path, all found
by the sashiko-bot AI reviewer:
- __open_dso() can return a file descriptor of 0 (stdin) when
dso__get_filename() fails without setting errno, so fd = -errno = 0
looked like a successfully opened DSO;
- dso__decompress_kmodule_path() calls close(fd) with fd = -1 when
decompression fails or the DSO is not compressed, clobbering errno
with EBADF on the error path;
- file_read() reads the stale global errno after try_to_open_dso()
fails, when by then errno has been through mutex_lock(),
nsinfo__mountns_enter() and several open() attempts;
- dso_cache__memcpy() underflows when cache->size is smaller than the
RB tree offset (short pread), computing a huge memcpy length;
- dso__read_symbol() asserts on an input-dependent condition instead
of doing a runtime check, keeping the BPF metadata safe from crafted
input.
Best regards,
- Arnaldo
What changed from v1 (20260802142022.154219-1-acme@kernel.org):
PATCH 1/5:
- __open_dso() now sets errno = ENOENT directly when
dso__get_filename() fails with errno == 0, instead of only computing
fd = -ENOENT. Callers that check errno after a negative fd (e.g.
file_read() returning -errno) no longer get 0/EOF for an open
failure [sashiko-bot review of PATCH 1/5].
- Rebased onto the current perf-tools-next head (bf10e6ee2ac3034c).
This series was developed with assistance from Claude (claude-opus-4.6)
and Opencode (deepseek-v4-flash-free) for code analysis, patch
generation, and commit message composition. All changes were validated
by the maintainer.
Arnaldo Carvalho de Melo (5):
perf dso: Guard against errno==0 when dso__get_filename() returns NULL
perf dso: Guard close() against invalid fd in
dso__decompress_kmodule_path()
perf dso: Use stored fd error instead of stale errno in file_read()
perf dso: Guard against cache underflow on short reads in
dso_cache__memcpy()
perf dso: Replace assert with runtime check in dso__read_symbol()
tools/perf/util/dso.c | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)
base-commit: bf10e6ee2ac3034c9068e03eed418fd16961984e
v1-head: f6cb9e46c7b8949b
next reply other threads:[~2026-08-11 17:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 17:11 Arnaldo Carvalho de Melo [this message]
2026-08-11 17:11 ` [PATCH 1/5] perf dso: Guard against errno==0 when dso__get_filename() returns NULL Arnaldo Carvalho de Melo
2026-08-11 17:11 ` [PATCH 2/5] perf dso: Guard close() against invalid fd in dso__decompress_kmodule_path() Arnaldo Carvalho de Melo
2026-08-11 17:11 ` [PATCH 3/5] perf dso: Use stored fd error instead of stale errno in file_read() Arnaldo Carvalho de Melo
2026-08-11 17:11 ` [PATCH 4/5] perf dso: Guard against cache underflow on short reads in dso_cache__memcpy() Arnaldo Carvalho de Melo
2026-08-11 17:12 ` [PATCH 5/5] perf dso: Replace assert with runtime check in dso__read_symbol() 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=20260811171200.30096-1-acme@kernel.org \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=song@kernel.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.com \
/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).