From: sashiko-bot@kernel.org
To: "Ivan Shapovalov" <intelfx@intelfx.name>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 2/4] perf: zstd: factor out zstd_init_{c,d}stream()
Date: Wed, 14 Oct 2026 17:43:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-171587@kernel.org> (raw)
In-Reply-To: <20261014-perf-zstd-v1-2-9652727886fa@intelfx.name>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] perf: zstd_decompress_buffer() returns SIZE_MAX instead of 0 on error
--
commit 1d761c8689bb9c7209c96548d100b2308a92f2a5
Author: Ivan Shapovalov <intelfx@intelfx.name>
perf: zstd: factor out zstd_init_{c,d}stream()
Factor out functions to manage CStream/DStream in struct zstd_data
for reuse across multiple zstd (de)compression entry points.
> diff --git a/tools/perf/util/zstd.c b/tools/perf/util/zstd.c
> index af113660d1ce0..3af8910bb87cf 100644
> --- a/tools/perf/util/zstd.c
> +++ b/tools/perf/util/zstd.c
[ ... ]
> @@ -107,24 +139,14 @@ ssize_t zstd_compress_stream_to_records(struct zstd_data *data, void *dst, size_
> size_t zstd_decompress_buffer(struct zstd_data *data, void *src, size_t src_size,
> void *dst, size_t dst_size)
> {
> - size_t ret;
> + ssize_t ret;
> ZSTD_inBuffer input = { src, src_size, 0 };
> ZSTD_outBuffer output = { dst, dst_size, 0 };
>
> - if (!data->dstream) {
> - data->dstream = ZSTD_createDStream();
> - if (data->dstream == NULL) {
> - pr_err("Couldn't create decompression stream.\n");
> - return 0;
> - }
> + ret = zstd_init_dstream(data);
> + if (ret < 0)
> + return ret;
[Severity: High]
Since zstd_decompress_buffer() returns a size_t, will returning a negative
error code here implicitly cast -1 to SIZE_MAX?
It looks like callers such as perf_session__process_compressed_event() check
for a 0 return to detect failure. If zstd_init_dstream() fails, wouldn't
returning SIZE_MAX cause the caller to treat it as a huge success,
potentially leading to massive out-of-bounds size increments?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261014-perf-zstd-v1-0-9652727886fa@intelfx.name?part=2
next prev parent reply other threads:[~2026-10-14 17:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 17:34 [PATCH 0/4] perf: support zstd-compressed kernel modules Ivan Shapovalov
2026-10-14 17:34 ` [PATCH 1/4] perf: zstd: zstd_decompress_stream -> zstd_decompress_buffer Ivan Shapovalov
2026-10-14 17:38 ` sashiko-bot
2026-10-14 17:34 ` [PATCH 2/4] perf: zstd: factor out zstd_init_{c,d}stream() Ivan Shapovalov
2026-10-14 17:43 ` sashiko-bot [this message]
2026-10-14 17:34 ` [PATCH 3/4] perf: zstd: add streaming decompression and format probe functions Ivan Shapovalov
2026-10-14 17:51 ` sashiko-bot
2026-10-14 17:34 ` [PATCH 4/4] perf: support zstd-compressed kernel modules Ivan Shapovalov
2026-10-14 17:58 ` 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=sashiko-outbox-171587@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intelfx@intelfx.name \
--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