All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aaron Tomlin" <atomlin@atomlin.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH perf-tools-next v2 4/4] perf tests: Add shell test for kernel symbol beautifier
Date: Sun, 16 Aug 2026 21:04:49 +0000	[thread overview]
Message-ID: <20260816210449.5F6E11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260816205921.576365-5-atomlin@atomlin.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] The regular expression used to verify kernel symbol beautification incorrectly matches raw hexadecimal addresses, causing the test to falsely pass even if symbolization fails.
- [Medium] Temporary file created by `mktemp` is leaked on early exits.
- [Low] Unquoted `$0` in `dirname` command substitution can cause the script to fail if the execution path contains spaces.
- [Low] Command output is directly interpolated into a `printf` format string, which will mangle output containing `%` or `\` characters.
--

--- Patch [4]: [PATCH perf-tools-next v2 4/4] perf tests: Add shell test for kernel symbol beautifier ---
commit 3b67c2553760890642357a39f8d2c206545b9020
Author: Aaron Tomlin <atomlin@atomlin.com>

perf tests: Add shell test for kernel symbol beautifier

Add a dedicated shell test script, trace_ksym_beautifier.sh, to verify
that 'perf trace' properly symbolises kernel virtual addresses and
function pointers using both the default kallsyms beautifier (SCA_KSYM)
and BTF type routing i.e., --force-btf.

> diff --git a/tools/perf/tests/shell/trace_ksym_beautifier.sh b/tools/perf/tests/shell/trace_ksym_beautifier.sh
> new file mode 100755
> index 0000000000000..2916f78503f71
> --- /dev/null
> +++ b/tools/perf/tests/shell/trace_ksym_beautifier.sh
> @@ -0,0 +1,52 @@
> +#!/bin/bash
> +# perf trace kernel symbol beautifier tests
> +# SPDX-License-Identifier: GPL-2.0
> +
> +err=0
> +OUTPUT=$(mktemp /tmp/perf_trace_test.XXXXX)
> +
> +# shellcheck source=lib/probe.sh
> +. "$(dirname $0)"/lib/probe.sh

[Severity: Low]
Does the unquoted $0 in this dirname substitution cause the script to fail if
the execution path contains spaces?

> +skip_if_no_perf_trace || exit 2
> +[ "$(id -u)" = 0 ] || exit 2

[Severity: Medium]
Since OUTPUT is created via mktemp before these early exit checks, and the
cleanup trap isn't registered until later, do these exits leak the temporary
file in /tmp?

> +
> +cleanup() {
> +  rm -f ${OUTPUT}
> +}
> +
> +trap cleanup EXIT TERM INT HUP
> +
> +test_ksym_kallsyms() {
> +  echo "Testing perf trace kernel symbol beautifier (default kallsyms)"
> +  perf trace -e kmem:kmalloc --max-events=1 > ${OUTPUT} 2>&1
> +  if ! grep -q -E "call_site: [a-zA-Z0-9_]+" ${OUTPUT}

[Severity: Medium]
Does this regular expression inadvertently match raw hexadecimal addresses?
Because the character x and hex digits fall within the [a-zA-Z0-9_]+
character class, it appears this could falsely pass if symbolization fails
and perf trace outputs un-symbolized addresses like 0xffffffff12345678.

> +  then
> +    printf "Default kallsyms function symbolization failed, output:\n$(cat ${OUTPUT})\n"

[Severity: Low]
Could directly interpolating the command output into the printf format string
cause issues? If the output contains % or \ characters, printf might
interpret them as format specifiers or escape sequences.

> +    err=1
> +  fi
> +}
> +
> +test_ksym_btf() {
> +  echo "Testing perf trace kernel symbol beautifier (BTF)"
> +  if [ ! -f /sys/kernel/btf/vmlinux ]; then
> +    echo "Skipping BTF test due to missing vmlinux BTF"
> +    return
> +  fi
> +
> +  perf trace -e kmem:kmalloc --force-btf --max-events=1 > ${OUTPUT} 2>&1
> +  if ! grep -q -E "call_site: [a-zA-Z0-9_]+" ${OUTPUT}

[Severity: Medium]
Similar to the kallsyms test above, does this regex incorrectly match raw hex
addresses when BTF symbolization fails?

> +  then
> +    printf "BTF function symbolization failed, output:\n$(cat ${OUTPUT})\n"

[Severity: Low]
As with the previous printf, does embedding the output directly into the
format string risk mangling the output if it contains format specifiers?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260816205921.576365-1-atomlin@atomlin.com?part=4

      reply	other threads:[~2026-08-16 21:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-16 20:59 [PATCH perf-tools-next v2 0/4] perf trace: Symbolise kernel virtual addresses and function pointers Aaron Tomlin
2026-08-16 20:59 ` [PATCH perf-tools-next v2 1/4] perf trace: Introduce kernel symbol beautifier for virtual addresses Aaron Tomlin
2026-08-16 21:04   ` sashiko-bot
2026-08-16 20:59 ` [PATCH perf-tools-next v2 2/4] perf trace: Auto-assign kernel symbol beautifier to function pointer fields Aaron Tomlin
2026-08-16 21:08   ` sashiko-bot
2026-08-16 20:59 ` [PATCH perf-tools-next v2 3/4] perf trace: Enhance BTF type formatting to symbolise kernel function pointers Aaron Tomlin
2026-08-16 21:11   ` sashiko-bot
2026-08-16 20:59 ` [PATCH perf-tools-next v2 4/4] perf tests: Add shell test for kernel symbol beautifier Aaron Tomlin
2026-08-16 21:04   ` 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=20260816210449.5F6E11F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=atomlin@atomlin.com \
    --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.