From: sashiko-bot@kernel.org
To: "Kunwu Chan" <kunwu.chan@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [RFC PATCH 5/5] selftests/perf_events: add AUX kernel API selftest script
Date: Fri, 14 Aug 2026 14:56:10 +0000 [thread overview]
Message-ID: <20260814145611.57F9C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260814144927.489172-6-kunwu.chan@linux.dev>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] Selftest unconditionally fails in installed environments by expecting kernel source files to be present.
- [Medium] Userspace regression test is improperly skipped when the selftest is run from an installed location.
- [Medium] Selftest hardcodes `gcc` for runtime compilation, breaking cross-compilation environments.
- [Medium] Insecure predictable temporary directory name in `/tmp` allows local arbitrary file overwrite.
--
--- Patch [5]: [RFC PATCH 5/5] selftests/perf_events: add AUX kernel API selftest script ---
commit 3dec31f6b5ec09fc257a6fee2e10670ad1c14b3c
Author: Kunwu Chan <kunwu.chan@gmail.com>
selftests/perf_events: add AUX kernel API selftest script
Add a shell script that runs the perf_aux_kernel KUnit suite through
debugfs, builds and runs the userspace regression program, and
performs static-analysis checks on the source tree.
> diff --git a/tools/testing/selftests/perf_events/aux_kernel.sh b/tools/testing/selftests/perf_events/aux_kernel.sh
> new file mode 100755
> index 0000000000000..431f59ef02e7d
> --- /dev/null
> +++ b/tools/testing/selftests/perf_events/aux_kernel.sh
> @@ -0,0 +1,563 @@
> +#!/bin/bash
[ ... ]
> +RESULTS_DIR="/tmp/perf_aux_kernel_test_$$"
> +mkdir -p "$RESULTS_DIR"
> +exec > >(tee "$RESULTS_DIR/output.log") 2>&1
[Severity: Medium]
Does this predictable temporary directory name create a local file overwrite
vulnerability?
Since this selftest might be executed as root, a local unprivileged user could
pre-create a symlink with the target PID pointing to any system file (like
/etc/shadow). The tee command would then follow the symlink and overwrite the
target file.
[ ... ]
> +SRC_EVENTS="$ROOT/kernel/events"
> +for f in core.c ring_buffer.c internal.h; do
> + if [[ -f "$SRC_EVENTS/$f" ]]; then
> + pass "Source file: kernel/events/$f"
> + else
> + fail "Source file: kernel/events/$f missing"
> + fi
> +done
[Severity: Medium]
Will this unconditionally fail in installed selftest environments?
When tests are run via make install on target CI systems, the kernel source
tree is typically not present. Checking for source files in kernel/events/ and
invoking fail() will cause false positive CI failures.
[ ... ]
> +# Build and run the C regression test program
> +UMODE_SRC="$SCRIPT_DIR/aux_kernel_usermode.c"
> +UMODE_BIN="$SCRIPT_DIR/aux_kernel_usermode"
> +
> +if [[ -f "$UMODE_SRC" ]]; then
> + if [[ ! -x "$UMODE_BIN" ]] || [[ "$UMODE_SRC" -nt "$UMODE_BIN" ]]; then
[Severity: Medium]
Will this skip the userspace regression test when run from an installed
location?
Because source files are not installed by TEST_GEN_PROGS during make install,
the source file won't exist on the target system. This conditional causes
the script to skip executing the already compiled binary, reducing test
coverage in CI pipelines.
> + echo " Building aux_kernel_usermode..."
> + gcc -o "$UMODE_BIN" "$UMODE_SRC" -Wall -Wextra -O2 2>&1 | \
[Severity: Medium]
Does hardcoding gcc break cross-compilation environments?
If the binary is missing and the script attempts to compile it dynamically,
using gcc ignores the CC and CROSS_COMPILE environment variables set by the
kernel build system. This can lead to compilation failures or building for
the wrong architecture.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260814144927.489172-1-kunwu.chan@linux.dev?part=5
prev parent reply other threads:[~2026-08-14 14:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 14:49 [RFC PATCH 0/5] perf/core: add AUX buffer kernel-consumer API Kunwu Chan
2026-08-14 14:49 ` [RFC PATCH 1/5] perf/core: add AUX buffer ownership for kernel events Kunwu Chan
2026-08-14 15:04 ` sashiko-bot
2026-08-14 14:49 ` [RFC PATCH 2/5] perf/core: add AUX ring accessors for kernel consumers Kunwu Chan
2026-08-14 14:59 ` sashiko-bot
2026-08-14 14:49 ` [RFC PATCH 3/5] perf/core: add KUnit tests for AUX kernel-consumer API Kunwu Chan
2026-08-14 15:02 ` sashiko-bot
2026-08-14 14:49 ` [RFC PATCH 4/5] selftests/perf_events: add userspace AUX regression test Kunwu Chan
2026-08-14 14:59 ` sashiko-bot
2026-08-14 14:49 ` [RFC PATCH 5/5] selftests/perf_events: add AUX kernel API selftest script Kunwu Chan
2026-08-14 14:56 ` 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=20260814145611.57F9C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kunwu.chan@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox