Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 8/8] perf test: Add file offset diagnostic test for corrupted perf.data
Date: Wed, 03 Jun 2026 01:32:05 +0000	[thread overview]
Message-ID: <20260603013206.09D571F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260602235709.1541603-9-acme@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Hardcoded little-endian byte sequence causes the test to fail on big-endian architectures.
--

commit af35d72bcb6cca8ee9ddf5a0da66e97329974342
Author: Arnaldo Carvalho de Melo <acme@redhat.com>

perf test: Add file offset diagnostic test for corrupted perf.data

This commit adds a shell test to verify that file_offset diagnostic messages
work correctly when perf encounters corrupted events. It intentionally
corrupts an MMAP2 event's size field in a recorded perf.data file and checks
that perf report produces a warning message that includes the file offset.

> diff --git a/tools/perf/tests/shell/data_file_offset_diagnostics.sh b/tools/perf/tests/shell/data_file_offset_diagnostics.sh
> new file mode 100755
> --- /dev/null
> +++ b/tools/perf/tests/shell/data_file_offset_diagnostics.sh

[ ... ]

> +# Copy the file and corrupt the MMAP2 event's size field.
> +# perf_event_header layout: type(u32) misc(u16) size(u16)
> +# Set size to 16 (0x10 0x00 little-endian) — below the MMAP2
> +# minimum, which triggers the "event size too small" warning.
> +cp "${perfdata}" "${corrupted}"
> +printf '\x10\x00' | dd of="${corrupted}" bs=1 seek=$((mmap2_offset_dec + 6)) conv=notrunc 2>/dev/null

[Severity: Medium]
Will this hardcoded little-endian byte sequence cause the test to fail on
big-endian architectures?

The test explicitly overwrites the 16-bit size field of a PERF_RECORD_MMAP2
event using the bytes \x10\x00. Since perf.data files are natively encoded
in the host system's byte order, on big-endian hosts (e.g., s390x) the
native u16 parsing of 0x10 at offset 0 and 0x00 at offset 1 will evaluate
to 0x1000 (4096).

Because 4096 exceeds the minimum MMAP2 event size, the internal validation
check is bypassed. This will cause perf report to skip 4096 bytes and
attempt to parse unaligned garbage data instead of emitting the expected
"too small" warning for the MMAP2 event.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260602235709.1541603-1-acme@kernel.org?part=8

      reply	other threads:[~2026-06-03  1:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02 23:56 [PATCHES 0/8] perf tools: Diagnostic offsets in skip messages + two hardening fixes Arnaldo Carvalho de Melo
2026-06-02 23:57 ` [PATCH 1/8] perf sample: Add file_offset field to struct perf_sample Arnaldo Carvalho de Melo
2026-06-02 23:57 ` [PATCH 2/8] perf session: Include file offset in event skip/stop messages Arnaldo Carvalho de Melo
2026-06-02 23:57 ` [PATCH 3/8] perf sched: Include file offset in event skip messages Arnaldo Carvalho de Melo
2026-06-02 23:57 ` [PATCH 4/8] perf timechart: Include file offset in CPU bounds check messages Arnaldo Carvalho de Melo
2026-06-03  0:36   ` sashiko-bot
2026-06-02 23:57 ` [PATCH 5/8] perf tools: Include file offset and event type name in skip messages Arnaldo Carvalho de Melo
2026-06-02 23:57 ` [PATCH 6/8] perf timechart: Fix cat_backtrace() use-after-free on corrupted callchain Arnaldo Carvalho de Melo
2026-06-02 23:57 ` [PATCH 7/8] perf sched: Replace BUG_ON on invalid CPU with graceful skip Arnaldo Carvalho de Melo
2026-06-03  1:16   ` sashiko-bot
2026-06-02 23:57 ` [PATCH 8/8] perf test: Add file offset diagnostic test for corrupted perf.data Arnaldo Carvalho de Melo
2026-06-03  1:32   ` 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=20260603013206.09D571F00898@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox