From: sashiko-bot@kernel.org
To: "Viktor Malik" <vmalik@redhat.com>
Cc: linux-perf-users@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH v2 1/2] perf trace: Factor out BPF loop body
Date: Fri, 03 Jul 2026 10:48:42 +0000 [thread overview]
Message-ID: <20260703104843.E21C51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20fc67aa2550ca5aff52b3a9a207f2e07f8e0b1d.1783070132.git.vmalik@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Zero-extension of map values makes the condition `size < 0` always false, resulting in dead code that completely breaks tracepoint buffer augmentation.
--
commit d586728f909e7c096ce4ad924848b781a274c29f
Author: Viktor Malik <vmalik@redhat.com>
perf trace: Factor out BPF loop body
This commit factors out the loop body in augmented_raw_syscalls into a
separate function. This is intended to simplify the code and help address
problems with the BPF verifier.
> diff --git a/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c b/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c
> --- a/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c
> +++ b/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c
[ ... ]
> +static inline int augment_arg(struct syscall_enter_args *args, int i,
> + unsigned int *beauty_map, void *payload_offset)
> +{
> + int index, value_size = sizeof(struct augmented_arg) - offsetof(struct augmented_arg, value);
> + s64 aug_size, size;
> + bool augmented;
> + void *arg;
> +
> + arg = (void *)args->args[i];
> + augmented = false;
> + size = beauty_map[i];
[ ... ]
> + } else if (size > 0 && size <= value_size) { /* struct */
> + if (!bpf_probe_read_user(((struct augmented_arg *)payload_offset)->value, size, arg))
> + augmented = true;
> + } else if ((int)size < 0 && size >= -6) { /* buffer */
[Severity: Medium]
Will this condition evaluate correctly given that beauty_map contains
unsigned integers?
When the userspace perf trace tool populates beauty_map_enter with negative
values (e.g., -1) to indicate buffer arguments, they are stored as 32-bit
unsigned integers (e.g., 4294967295).
Since size is an s64, reading from the map via size = beauty_map[i]
zero-extends this unsigned value, making it strictly non-negative.
It appears a subsequent patch in this series removes the (int) cast to
address an out-of-bounds array access caused by the size >= -6 check
(which was a pre-existing issue).
However, removing that cast leaves the condition checking if size < 0,
which will always be false because of the zero-extension.
Could this inadvertently turn the entire buffer augmentation branch into
dead code, systematically failing to augment every buffer tracepoint
argument?
> + index = -(size + 1);
> + barrier_var(index); // Prevent clang (noticed with v18) from removing the &= 7 trick.
> + index &= 7; // Satisfy the bounds checking with the verifier in some kernels.
> + aug_size = args->args[index] > TRACE_AUG_MAX_BUF ? TRACE_AUG_MAX_BUF : args->args[index];
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1783070132.git.vmalik@redhat.com?part=1
next prev parent reply other threads:[~2026-07-03 10:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 10:32 [PATCH v2 0/2] perf trace: Refactor augmented_raw_syscalls using bpf_for Viktor Malik
2026-07-03 10:32 ` [PATCH v2 1/2] perf trace: Factor out BPF loop body Viktor Malik
2026-07-03 10:48 ` sashiko-bot [this message]
2026-07-03 23:49 ` Namhyung Kim
2026-07-06 10:42 ` Viktor Malik
2026-07-03 10:32 ` [PATCH v2 2/2] perf trace: Refactor augmented_raw_syscalls using bpf_for Viktor Malik
2026-07-03 10:45 ` sashiko-bot
2026-07-03 11:39 ` Viktor Malik
2026-07-03 23:50 ` Namhyung Kim
2026-07-06 10:46 ` Viktor Malik
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=20260703104843.E21C51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vmalik@redhat.com \
/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