From: sashiko-bot@kernel.org
To: "Tanushree Shah" <tshah@linux.ibm.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [RFC PATCH v4 3/5] perf data-convert: Add perf.data to trace.dat conversion backend
Date: Sat, 22 Aug 2026 06:38:42 +0000 [thread overview]
Message-ID: <20260822063842.640C51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260822062729.882005-4-tshah@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Arbitrary file truncation and TOCTOU vulnerability via symlink in the `--force` path.
- [Medium] Directly accessing `perf_env` field without verifying initialization.
- [Low] Missing feature fallback stub for `trace_convert__perf2dat` in `data-convert.h`.
- [Low] Lost error code when `fopen()` fails in the `--force` path.
--
--- Patch [3]: [RFC PATCH v4 3/5] perf data-convert: Add perf.data to trace.dat conversion backend ---
commit aaf748bbf23e74fad4be33c3834c0413e8def0f8
Author: Tanushree Shah <tshah@linux.ibm.com>
perf data-convert: Add perf.data to trace.dat conversion backend
This commit adds a new conversion backend to perf to translate tracepoint
events from perf.data into trace.dat format. It leverages a new per-CPU
buffering mechanism and implements required callbacks for pipe mode.
> diff --git a/tools/perf/util/data-convert-trace.c b/tools/perf/util/data-convert-trace.c
> new file mode 100644
> index 0000000000000..445479fae8884
> --- /dev/null
> +++ b/tools/perf/util/data-convert-trace.c
[ ... ]
> + /*
> + * In pipe mode, CPU count and page size arrive via feature/tracing_data
> + * records before the first sample; initialize buffers lazily on first sample.
> + */
> + if (!cpu_buffers_initialized) {
> + int nr_cpus = trace_dat_session->header.env.nr_cpus_online;
[Severity: Medium]
Is it safe to access nr_cpus_online directly here without first verifying the
environment is initialized?
The perf subsystem guidelines suggest that accessing perf_env fields without
first verifying those fields are populated can lead to bugs.
[ ... ]
> + if (!opts->force) {
> + int fd = open(to_trace, O_WRONLY | O_CREAT | O_EXCL, 0644);
[ ... ]
> + } else {
> + trace_dat_fp = fopen(to_trace, "wb");
[Severity: High]
Could this fopen() in the --force path be susceptible to an arbitrary file
truncation symlink attack?
If an attacker creates a symlink at the destination path, fopen() with "wb"
will follow it and truncate the target file. If the conversion subsequently
fails, the cleanup routine calls unlink(to_trace), which removes the symlink
itself. This leaves the target file truncated while hiding the attacker's
symlink from discovery.
> + if (!trace_dat_fp) {
> + pr_err("Failed to open output file: %s\n", to_trace);
> + return -EINVAL;
[Severity: Low]
Should this return the actual -errno from fopen() instead of a hardcoded
-EINVAL so the exact filesystem error is not lost?
> + }
> + }
[ ... ]
> diff --git a/tools/perf/util/data-convert.h b/tools/perf/util/data-convert.h
> index a96240f156712..f041c23252263 100644
> --- a/tools/perf/util/data-convert.h
> +++ b/tools/perf/util/data-convert.h
[ ... ]
> +#ifdef HAVE_LIBTRACEEVENT
> +int trace_convert__perf2dat(const char *input, const char *to_trace,
> + struct perf_data_convert_opts *opts);
> +#endif /* HAVE_LIBTRACEEVENT */
[Severity: Low]
Does this declaration need an #else block with a compatible dummy inline stub?
Without a fallback stub when HAVE_LIBTRACEEVENT is absent, callers might
be forced to clutter their code with preprocessor blocks to prevent build
failures.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260822062729.882005-1-tshah@linux.ibm.com?part=3
next prev parent reply other threads:[~2026-08-22 6:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-22 6:27 [RFC PATCH v4 0/5] Add perf.data tracepoint events to trace.dat conversion Tanushree Shah
2026-08-22 6:27 ` [RFC PATCH v4 1/5] perf/trace-dat: Add trace.dat export infrastructure Tanushree Shah
2026-08-22 6:40 ` sashiko-bot
2026-08-22 6:27 ` [RFC PATCH v4 2/5] perf/trace-event: Write trace.dat metadata sections during parsing Tanushree Shah
2026-08-22 6:44 ` sashiko-bot
2026-08-22 6:27 ` [RFC PATCH v4 3/5] perf data-convert: Add perf.data to trace.dat conversion backend Tanushree Shah
2026-08-22 6:38 ` sashiko-bot [this message]
2026-08-22 6:27 ` [RFC PATCH v4 4/5] perf data: Add --to-trace-dat option for converting perf.data tracepoint events into trace.dat format Tanushree Shah
2026-08-22 6:44 ` sashiko-bot
2026-08-22 6:27 ` [RFC PATCH v4 5/5] perf test: Add test validating trace.dat generated by 'perf data convert --to-trace-dat' Tanushree Shah
2026-08-22 6:36 ` 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=20260822063842.640C51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tshah@linux.ibm.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