From: sashiko-bot@kernel.org
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 2/8] perf debuginfo: Fetch debuginfo keyed by build ID using debuginfod
Date: Sun, 13 Sep 2026 02:47:01 +0000 [thread overview]
Message-ID: <20260913024701.719C31F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260913023459.112654-3-acme@kernel.org>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] Concurrent calls to `setenv()` cause undefined behavior and Use-After-Free crashes.
- [High] Concurrent modifications to process-global terminal settings and signal handlers cause permanent corruption.
- [Medium] Data races on static variables (`debuginfod_fetch_cancelled`, `debuginfod_signal`, `debuginfod_progress_started`) corrupt concurrent fetches.
- [Medium] Intercepted signals (e.g., SIGINT) are swallowed on the success path, preventing graceful termination.
- [Low] Missing explicit inclusion of `<limits.h>` for `PATH_MAX`, causing musl libc compilation failures.
--
commit 93a135dd9f8083fd8291b38e49e5952c517a78da
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf debuginfo: Fetch debuginfo keyed by build ID using debuginfod
This commit adds support for fetching debuginfo keyed by build ID from
debuginfod servers. It integrates this into the DSO debuginfo resolution
path as a fallback when local debuginfo is missing.
> diff --git a/tools/perf/util/debuginfo.c b/tools/perf/util/debuginfo.c
> --- a/tools/perf/util/debuginfo.c
> +++ b/tools/perf/util/debuginfo.c
[ ... ]
> @@ -139,6 +148,369 @@ struct debuginfo *debuginfo__new(const char *path)
[ ... ]
> +static void debuginfod__setup_urls_env(void)
> +{
> + char *urls = NULL;
> + DIR *dir;
> + struct dirent *dent;
> +
> + if (getenv("DEBUGINFOD_URLS") != NULL)
> + return;
> +
> + dir = opendir("/etc/debuginfod");
> + if (dir == NULL)
> + return;
> +
> + while ((dent = readdir(dir)) != NULL) {
> + char *content = NULL;
> + char *new_urls;
> + char path[PATH_MAX];
[Severity: Low]
Does the use of PATH_MAX without an explicit inclusion of <limits.h> cause
build failures on systems using musl libc?
> + size_t len = strlen(dent->d_name), i, size;
> + int n;
[ ... ]
> + if (urls != NULL) {
> + setenv("DEBUGINFOD_URLS", urls, 1);
[Severity: High]
Since dso__debuginfo() explicitly drops the dso__lock before falling back to
fetch debuginfo, we can have a call chain like this executed concurrently:
Thread 1 & 2:
dso__debuginfo() -> drops lock
debuginfo__new_build_id()
debuginfo__find_build_id()
debuginfod__setup_urls_env()
setenv()
Can concurrent threads resolving DSOs call setenv() simultaneously here? Because
setenv() is thread-unsafe, this concurrent access could corrupt the process-global
environment array and cause a crash.
> + pr_debug("Set DEBUGINFOD_URLS from /etc/debuginfod: %s\n", urls);
> + }
> + free(urls);
> +}
[ ... ]
> +int debuginfo__find_build_id(const struct build_id *bid, char **path)
> +{
> + char sbuild_id[SBUILD_ID_SIZE];
> + struct termios orig_termios;
> + struct sigaction sa, orig_sigint, orig_sigterm;
> + bool term_set = false, sigint_set = false, sigterm_set = false;
> + debuginfod_client *c;
> + int fd;
[ ... ]
> + debuginfod_fetch_cancelled = false;
> + debuginfod_signal = 0;
[Severity: Medium]
These static global variables are shared across all threads but modified here
without synchronization. If a second thread starts a fetch, could it
unconditionally reset debuginfod_fetch_cancelled to false and cause a concurrent
thread attempting to cancel its blocked fetch to hang indefinitely?
> +
> + /*
> + * Make stdin deliver keypresses without waiting for a newline,
> + * the progress callback above polls it for the 's'/'d' keys,
[ ... ]
> + if (isatty(STDIN_FILENO) && isatty(STDERR_FILENO) && !use_browser) {
> + set_term_quiet_input(&orig_termios);
> + term_set = true;
> +
> + memset(&sa, 0, sizeof(sa));
> + sa.sa_handler = debuginfod_signal_handler;
> + sigemptyset(&sa.sa_mask);
> + if (sigaction(SIGINT, &sa, &orig_sigint) == 0)
> + sigint_set = true;
> + if (sigaction(SIGTERM, &sa, &orig_sigterm) == 0)
> + sigterm_set = true;
> + }
[Severity: High]
Following the same concurrent execution path from dso__debuginfo(), can multiple
threads concurrently modify the process-wide terminal attributes and signal
handlers here?
If Thread B captures Thread A's temporary raw state into orig_termios, could it
eventually restore that state permanently and leave the process terminal broken
after the fetches complete?
> +
> + fd = debuginfod_find_debuginfo(c, bid->data, bid->size, path);
> +
> + if (term_set)
> + tcsetattr(STDIN_FILENO, TCSANOW, &orig_termios);
> + if (sigint_set)
> + sigaction(SIGINT, &orig_sigint, NULL);
> + if (sigterm_set)
> + sigaction(SIGTERM, &orig_sigterm, NULL);
> +
> + debuginfod_end(c);
> + if (debuginfod_progress_started) {
> + fputc('\n', stderr);
> + debuginfod_progress_started = false;
> + }
> + if (fd < 0) {
> + build_id__snprintf(bid, sbuild_id, sizeof(sbuild_id));
> + if (debuginfod_fetch_cancelled || debuginfod_signal) {
> + pr_debug("debuginfod search for build ID %s cancelled by the user\n",
> + sbuild_id);
> + /*
> + * The terminal is restored, die as the user asked;
> + * the original dispositions are back in place.
> + */
> + if (debuginfod_signal)
> + raise(debuginfod_signal);
> + return -1;
> + }
> + pr_debug("No debuginfo found for build ID %s in debuginfod\n",
> + sbuild_id);
> + debuginfod__miss_add(bid);
> + return -1;
> + }
> +
> + close(fd);
> + return 0;
> +}
[Severity: Medium]
On the success path when fd is valid, the code returns 0 and skips evaluating
and re-raising debuginfod_signal. Does this mean user interrupt requests like
SIGINT are silently swallowed if the user presses Ctrl-C right as the fetch is
concluding successfully?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260913023459.112654-1-acme@kernel.org?part=2
next prev parent reply other threads:[~2026-09-13 2:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-13 2:34 [PATCH v1 0/8] perf tools: Annotate fixes, stdio progress indication, debuginfo-client in more places Arnaldo Carvalho de Melo
2026-09-13 2:34 ` [PATCH v1 1/8] perf test: Skip data_type_profiling when the PMU cannot record memory events Arnaldo Carvalho de Melo
2026-09-13 2:40 ` sashiko-bot
2026-09-13 2:34 ` [PATCH v1 2/8] perf debuginfo: Fetch debuginfo keyed by build ID using debuginfod Arnaldo Carvalho de Melo
2026-09-13 2:47 ` sashiko-bot [this message]
2026-09-13 2:34 ` [PATCH v1 3/8] perf symbol: Fall back to fetching the vmlinux by build ID Arnaldo Carvalho de Melo
2026-09-13 2:43 ` sashiko-bot
2026-09-13 2:34 ` [PATCH v1 4/8] perf annotate-data: Show the sample count in the data-type browser Arnaldo Carvalho de Melo
2026-09-13 2:43 ` sashiko-bot
2026-09-13 2:34 ` [PATCH v1 5/8] perf report: Add --progress option Arnaldo Carvalho de Melo
2026-09-13 2:42 ` sashiko-bot
2026-09-13 2:34 ` [PATCH v1 6/8] perf scripts: Add perf-stuck, to tell where a running perf is stuck Arnaldo Carvalho de Melo
2026-09-13 2:44 ` sashiko-bot
2026-09-13 2:34 ` [PATCH v1 7/8] perf annotate-data: Resolve type DIEs in the debug file they came from Arnaldo Carvalho de Melo
2026-09-13 2:44 ` sashiko-bot
2026-09-13 2:34 ` [PATCH v1 8/8] perf mem record: Request PERF_SAMPLE_CPU by default Arnaldo Carvalho de Melo
2026-09-13 2:53 ` 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=20260913024701.719C31F000FF@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.