All of lore.kernel.org
 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 4/4] perf: support zstd-compressed kernel modules
Date: Wed, 14 Oct 2026 17:58:31 +0000	[thread overview]
Message-ID: <sashiko-outbox-171638@kernel.org> (raw)
In-Reply-To: <20261014-perf-zstd-v1-4-9652727886fa@intelfx.name>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] perf: Incorrect pointer arithmetic breaks gzip/xz module detection
--

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

perf: support zstd-compressed kernel modules

This commit adds support for handling zstd-compressed DSOs in perf. It allows
perf to load zstd-compressed kernel modules by identifying the .zst extension.

> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index 42bfe30a3b518..0e8886172e239 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
[ ... ]
> @@ -460,7 +463,7 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
>  
>  	m->comp = is_supported_compression(ext + 1);
>  	if (m->comp > COMP_ID__NONE)
> -		ext -= 3;
> +		ext -= strlen(compressions[m->comp].fmt);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: High]
Does this pointer arithmetic break the detection of gzip and xz compressed
modules?

When parsing a compressed module path like foo.ko.gz, ext initially points
to the last dot (for example, the dot before gz).

To check for the .ko extension, the code must shift the pointer backward by
3 bytes to point to the dot in .ko. The original code subtracted 3 because
the string .ko is exactly 3 bytes long.

By subtracting the length of the compression format string instead, this
now subtracts 2 for gz and xz formats. This shifts the pointer to the
character o in .ko rather than the dot.

The subsequent check in __kmod_path__parse():

	if (ext > name)
		m->kmod = !strncmp(ext, ".ko", 3);

will then compare o.g or o.x to .ko, which fails. This causes perf to
silently ignore .ko.gz and .ko.xz files and incorrectly flag them as not
being kernel modules.

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

      reply	other threads:[~2026-10-14 17:58 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
2026-10-14 17:34 ` [PATCH 4/4] perf: support zstd-compressed kernel modules Ivan Shapovalov
2026-10-14 17:58   ` sashiko-bot [this message]

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-171638@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 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.