Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ivan Shapovalov" <intelfx@intelfx.name>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 3/4] perf: zstd: add streaming decompression and format probe functions
Date: Wed, 14 Oct 2026 17:51:34 +0000	[thread overview]
Message-ID: <sashiko-outbox-171613@kernel.org> (raw)
In-Reply-To: <20261014-perf-zstd-v1-3-9652727886fa@intelfx.name>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] perf tools: zstd_is_compressed() returns true on file open failure
- [Low] perf: missing explicit <stdint.h> and <endian.h> for musl compatibility
--

commit a4c94e50df0d36cb48138075042eb1c0c1527f18
Author: Ivan Shapovalov <intelfx@intelfx.name>

    perf: zstd: add streaming decompression and format probe functions
    
    Add an actual streaming zstd decompression (fd->fd) entry point,
    plus a file->fd wrapper and a helper to detect zstd magic on a file
    for compressions[] in dso.c.

> diff --git a/tools/perf/util/zstd.c b/tools/perf/util/zstd.c
> index 3af8910bb87cf..982655a1f1a51 100644
> --- a/tools/perf/util/zstd.c
> +++ b/tools/perf/util/zstd.c

[ ... ]

> @@ -172,3 +176,103 @@ size_t zstd_decompress_buffer(struct zstd_data *data, void *src, size_t src_size

[ ... ]

> +bool zstd_is_compressed(const char *file)
> +{
> +	int fd = open(file, O_RDONLY);
> +	const uint32_t magic_le = htole32(ZSTD_MAGICNUMBER);

[Severity: Low]
Does this code need explicit inclusions for <stdint.h> and <endian.h>?

It appears compiling perf tools with musl libc could result in a build failure
here, since musl enforces strict POSIX header namespace separation and does not
leak uint32_t and htole32 through other standard library headers.

> +	char buf[4];
> +	ssize_t rc;
> +
> +	if (fd < 0) {
> +		pr_err("zstd: failed to open(%s): %s\n", file, strerror(errno));
> +		return -1;

[Severity: Medium]
Since zstd_is_compressed() returns a bool, does returning -1 here implicitly
evaluate to true?

If open() fails, returning true could cause callers probing file formats to
erroneously identify missing or unreadable files as valid ZSTD-compressed
archives. This could break fallback logic and lead to downstream decompression
attempts on missing files.

> +	}
> +
> +	rc = read(fd, buf, sizeof(buf));
> +	close(fd);
> +	return rc == sizeof(buf) ?
> +	       memcmp(buf, (const char *) &magic_le, sizeof(buf)) == 0 : false;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261014-perf-zstd-v1-0-9652727886fa@intelfx.name?part=3

  reply	other threads:[~2026-10-14 17:51 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
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 [this message]
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-171613@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