From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v7 3/5] perf synthetic-events: Fix stack buffer overflow and bounds in cgroup synthesis
Date: Wed, 22 Jul 2026 00:04:38 +0000 [thread overview]
Message-ID: <20260722000438.F0D951F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260721235254.294053-4-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Pre-existing 1-byte stack buffer overflow when appending a slash to the cgroup mount point.
- [High] Calling pthread_join() on uninitialized thread IDs during error cleanup.
--
--- Patch [3]: [PATCH v7 3/5] perf synthetic-events: Fix stack buffer overflow and bounds in cgroup synthesis ---
commit 65d6809cf0ab7cea41d6812171193757a21f8d99
Author: Ian Rogers <irogers@google.com>
perf synthetic-events: Fix stack buffer overflow and bounds in cgroup synthesis
The commit fixes a stack buffer overflow bug in perf_event__synthesize_cgroup()
by eliminating in-place path mutation. It uses PERF_ALIGN for path_len, clamps
raw_path_len, and uses strlcpy to prevent overruns.
> diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
> index e9952c27b3bc0..7b8095e013b98 100644
> --- a/tools/perf/util/synthetic-events.c
> +++ b/tools/perf/util/synthetic-events.c
> @@ -635,15 +635,22 @@ static int perf_event__synthesize_cgroup(const struct perf_tool *tool,
> struct machine *machine)
> {
> size_t event_size = sizeof(event->cgroup) - sizeof(event->cgroup.path);
[ ... ]
This is a pre-existing issue, but I noticed a potential problem in
perf_event__synthesize_cgroups():
tools/perf/util/synthetic-events.c:perf_event__synthesize_cgroups() {
...
char cgrp_root[PATH_MAX];
...
if (cgroupfs_find_mountpoint(cgrp_root, PATH_MAX, "perf_event") < 0) {
...
/* make sure the path starts with a slash (after mount point) */
strcat(cgrp_root, "/");
...
}
[Severity: High]
Can this strcat() cause a 1-byte stack buffer overflow if the mount point
path returned by cgroupfs_find_mountpoint() is PATH_MAX - 1 bytes long?
cgroupfs_find_mountpoint() can return paths up to PATH_MAX - 1 characters
(4095 bytes) into the cgrp_root buffer of size PATH_MAX.
When strcat() appends the "/", the '/' would be written at index 4095 and the
NUL terminator at index 4096.
Since cgrp_root is sized PATH_MAX (valid indices 0 to 4095), writing the NUL
terminator at index 4096 causes an overflow. While a 4095-byte mount path is
uncommon, it seems structurally possible.
This is also a pre-existing issue, but I noticed a potential problem in the
error handling path of perf_event__synthesize_threads():
tools/perf/util/synthetic-events.c:perf_event__synthesize_threads() {
...
synthesize_threads = calloc(thread_nr, sizeof(pthread_t));
...
for (i = 0; i < thread_nr; i++) {
if (pthread_create(&synthesize_threads[i], NULL,
synthesize_threads_worker, &args[i]))
goto out_join;
}
err = 0;
out_join:
for (i = 0; i < thread_nr; i++)
pthread_join(synthesize_threads[i], NULL);
...
}
[Severity: High]
Is it safe to join uninitialized threads in this error cleanup loop?
If pthread_create() fails, the code jumps to out_join. The cleanup loop then
unconditionally iterates through all thread_nr elements, calling
pthread_join().
Because synthesize_threads was allocated with calloc, the uninitialized or
failed thread IDs are 0.
On libc implementations like musl where pthread_t is a pointer, passing 0
results in a NULL pointer dereference inside pthread_join(), which could crash
the application during the error recovery path.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721235254.294053-1-irogers@google.com?part=3
next prev parent reply other threads:[~2026-07-22 0:04 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 17:54 [PATCH v1 0/4] perf: Fix and optimize maps parsing, boundaries, and bounds safety Ian Rogers
2026-07-20 17:54 ` [PATCH v1 1/4] perf find-map: Remove PATH_MAX 128-byte stack array restriction Ian Rogers
2026-07-20 18:05 ` sashiko-bot
2026-07-20 17:54 ` [PATCH v1 2/4] perf synthetic-events: Fix line synchronization, bounds, and truncation bugs in proc maps reader Ian Rogers
2026-07-20 18:08 ` sashiko-bot
2026-07-20 17:54 ` [PATCH v1 3/4] perf synthetic-events: Fix bounds, stale state, and misc flags in kernel module synthesis Ian Rogers
2026-07-20 17:54 ` [PATCH v1 4/4] perf synthetic-events: Fix bounds and union member access in mmap2 build_id synthesis Ian Rogers
2026-07-20 18:28 ` sashiko-bot
2026-07-20 22:51 ` [PATCH v2 0/4] perf: Fix and optimize maps parsing, boundaries, and bounds safety Ian Rogers
2026-07-20 22:51 ` [PATCH v2 1/4] perf find-map: Remove PATH_MAX 128-byte stack array restriction Ian Rogers
2026-07-20 22:51 ` [PATCH v2 2/4] perf synthetic-events: Fix line synchronization, bounds, and truncation bugs in proc maps reader Ian Rogers
2026-07-20 23:03 ` sashiko-bot
2026-07-20 22:51 ` [PATCH v2 3/4] perf synthetic-events: Fix bounds, stale state, and misc flags in kernel module synthesis Ian Rogers
2026-07-20 22:52 ` [PATCH v2 4/4] perf synthetic-events: Fix bounds and union member access in mmap2 build_id synthesis Ian Rogers
2026-07-21 17:33 ` [PATCH v3 0/4] perf: Fix and optimize maps parsing, boundaries, and bounds safety Ian Rogers
2026-07-21 17:33 ` [PATCH v3 1/4] perf find-map: Remove PATH_MAX 128-byte stack array restriction Ian Rogers
2026-07-21 17:33 ` [PATCH v3 2/4] perf synthetic-events: Fix line synchronization, bounds, and truncation bugs in proc maps reader Ian Rogers
2026-07-21 17:48 ` sashiko-bot
2026-07-21 17:33 ` [PATCH v3 3/4] perf synthetic-events: Fix bounds, stale state, and misc flags in kernel module synthesis Ian Rogers
2026-07-21 17:47 ` sashiko-bot
2026-07-21 17:33 ` [PATCH v3 4/4] perf synthetic-events: Fix bounds and union member access in mmap2 build_id synthesis Ian Rogers
2026-07-21 18:21 ` [PATCH v4 0/4] perf: Fix and optimize maps parsing, boundaries, and bounds safety Ian Rogers
2026-07-21 18:21 ` [PATCH v4 1/4] perf find-map: Remove PATH_MAX 128-byte stack array restriction Ian Rogers
2026-07-21 18:21 ` [PATCH v4 2/4] perf synthetic-events: Fix line synchronization, bounds, and truncation bugs in proc maps reader Ian Rogers
2026-07-21 19:26 ` sashiko-bot
2026-07-21 18:21 ` [PATCH v4 3/4] perf synthetic-events: Fix bounds, stale state, and misc flags in kernel module synthesis Ian Rogers
2026-07-21 18:21 ` [PATCH v4 4/4] perf synthetic-events: Fix bounds and union member access in mmap2 build_id synthesis Ian Rogers
2026-07-21 19:25 ` sashiko-bot
2026-07-21 20:57 ` [PATCH v5 0/4] perf: Fix and optimize maps parsing, boundaries, and bounds safety Ian Rogers
2026-07-21 20:57 ` [PATCH v5 1/4] perf find-map: Remove PATH_MAX 128-byte stack array restriction Ian Rogers
2026-07-21 20:57 ` [PATCH v5 2/4] perf synthetic-events: Fix line synchronization, bounds, and truncation bugs in proc maps reader Ian Rogers
2026-07-21 21:15 ` sashiko-bot
2026-07-21 20:57 ` [PATCH v5 3/4] perf synthetic-events: Fix bounds, stale state, and misc flags in kernel module synthesis Ian Rogers
2026-07-21 20:57 ` [PATCH v5 4/4] perf synthetic-events: Fix bounds and union member access in mmap2 build_id synthesis Ian Rogers
2026-07-21 23:09 ` [PATCH v6 0/4] perf: Fix and optimize maps parsing, boundaries, and bounds safety Ian Rogers
2026-07-21 23:09 ` [PATCH v6 1/4] perf find-map: Remove PATH_MAX 128-byte stack array restriction Ian Rogers
2026-07-21 23:09 ` [PATCH v6 2/4] perf synthetic-events: Fix line synchronization, bounds, and truncation bugs in proc maps reader Ian Rogers
2026-07-21 23:24 ` sashiko-bot
2026-07-21 23:09 ` [PATCH v6 3/4] perf synthetic-events: Fix bounds, stale state, and misc flags in kernel module synthesis Ian Rogers
2026-07-21 23:09 ` [PATCH v6 4/4] perf synthetic-events: Fix bounds and union member access in mmap2 build_id synthesis Ian Rogers
2026-07-21 23:52 ` [PATCH v7 0/5] perf: Fix and optimize maps parsing, boundaries, and bounds safety Ian Rogers
2026-07-21 23:52 ` [PATCH v7 1/5] perf find-map: Remove PATH_MAX 128-byte stack array restriction Ian Rogers
2026-07-21 23:52 ` [PATCH v7 2/5] perf synthetic-events: Fix line synchronization, bounds, and truncation bugs in proc maps reader Ian Rogers
2026-07-22 0:10 ` sashiko-bot
2026-07-21 23:52 ` [PATCH v7 3/5] perf synthetic-events: Fix stack buffer overflow and bounds in cgroup synthesis Ian Rogers
2026-07-22 0:04 ` sashiko-bot [this message]
2026-07-21 23:52 ` [PATCH v7 4/5] perf synthetic-events: Fix bounds, stale state, and misc flags in kernel module synthesis Ian Rogers
2026-07-21 23:52 ` [PATCH v7 5/5] perf synthetic-events: Fix bounds and union member access in mmap2 build_id synthesis Ian Rogers
2026-07-22 0:13 ` [PATCH v7 0/5] perf: Fix and optimize maps parsing, boundaries, and bounds safety Ian Rogers
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=20260722000438.F0D951F000E9@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