From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v6 6/6] perf aslr: Strip sample registers
Date: Fri, 08 May 2026 21:49:11 +0000 [thread overview]
Message-ID: <20260508214911.ADD7AC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260508082726.2795191-7-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Stripping register feature bits from event attributes while retaining the ABI word in the payload permanently misaligns downstream parsers.
- [High] In pipe mode, dynamically clearing register bits from ATTR events causes `perf inject` to misinterpret incoming raw SAMPLE events, leading to out-of-bounds reads and silent sample drops.
--
commit 2f6701e115da3f7f7833ab4467a9c51f40012620
Author: Ian Rogers <irogers@google.com>
perf aslr: Strip sample registers
This commit modifies the perf ASLR tool to strip register dump payload words
from sample events instead of dropping the entire sample. It also strips the
corresponding sample bit flags from the event attributes to keep downstream
parsers synchronized.
> diff --git a/tools/perf/util/aslr.c b/tools/perf/util/aslr.c
> index 09b7f2f8fb850..e5369589a7338 100644
> --- a/tools/perf/util/aslr.c
> +++ b/tools/perf/util/aslr.c
> @@ -751,18 +751,13 @@ static int aslr_tool__process_sample(const struct perf_tool *tool, union perf_ev
> if (abi != PERF_SAMPLE_REGS_ABI_NONE) {
> u64 nr = hweight64(evsel->core.attr.sample_regs_user);
>
> - if (nr > max_i - i || nr > max_j - j) {
> + if (nr > max_i - i) {
> ret = -EFAULT;
> goto out_put;
> }
> - memcpy(&out_array[j], &in_array[i], nr * sizeof(u64));
> i += nr;
> - j += nr;
> + out_array[j-1] = PERF_SAMPLE_REGS_ABI_NONE;
Since the PERF_SAMPLE_REGS_USER bit is completely cleared from the event's
sample_type bitmask, downstream parsers will not expect an ABI word and will
not advance their read pointer.
Does leaving the 8-byte ABI word in out_array permanently misalign downstream
parsers? It seems they might misinterpret this leftover word as the data for
the next field present in the bitmask sequence, shifting all subsequent sample
fields.
> }
[ ... ]
> @@ -907,6 +897,15 @@ static int aslr_tool__process_attr(const struct perf_tool *tool,
> if (new_event->attr.attr.type == PERF_TYPE_BREAKPOINT)
> new_event->attr.attr.bp_addr = 0; /* Conservatively remove addresses. */
>
> + if (new_event->attr.attr.sample_type & PERF_SAMPLE_REGS_USER) {
> + new_event->attr.attr.sample_type &= ~PERF_SAMPLE_REGS_USER;
> + new_event->attr.attr.sample_regs_user = 0;
> + }
> + if (new_event->attr.attr.sample_type & PERF_SAMPLE_REGS_INTR) {
> + new_event->attr.attr.sample_type &= ~PERF_SAMPLE_REGS_INTR;
> + new_event->attr.attr.sample_regs_intr = 0;
> + }
> +
In pipe mode, ATTR events arrive dynamically before SAMPLE events. If we
intercept these ATTR events and strip the register bits from the session's
internal evsel, will aslr_tool__process_sample() still be able to parse
incoming raw SAMPLE events correctly?
Because the bits would be missing from evsel->core.attr.sample_type, it
looks like the parser will skip the register parsing logic and fail to
advance its read pointer over the ABI word and register dump that are actually
present in the raw input payload. This could cause it to read subsequent
fields from the middle of the register dump.
> return delegate->attr(delegate, new_event, pevlist);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260508082726.2795191-1-irogers@google.com?part=6
prev parent reply other threads:[~2026-05-08 21:49 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 22:05 [PATCH v1 1/2] perf inject/aslr: Add aslr tool to remap/obfuscate virtual addresses Ian Rogers
2026-04-24 22:05 ` [PATCH v1 2/2] perf test: Add inject ASLR test Ian Rogers
2026-04-24 22:47 ` sashiko-bot
2026-04-24 22:36 ` [PATCH v1 1/2] perf inject/aslr: Add aslr tool to remap/obfuscate virtual addresses sashiko-bot
2026-04-25 2:05 ` [PATCH v2 " Ian Rogers
2026-04-25 2:05 ` [PATCH v2 2/2] perf test: Add inject ASLR test Ian Rogers
2026-05-04 3:51 ` [PATCH v3 0/4] perf tools: Add inject --aslr feature and prerequisite robustness fixes Ian Rogers
2026-05-04 3:51 ` [PATCH v3 1/4] perf sched: Add missing mmap2 handler in timehist Ian Rogers
2026-05-04 3:51 ` [PATCH v3 2/4] perf tool: Fix missing schedstat delegates and dont_split_sample_group in delegate_tool Ian Rogers
2026-05-04 3:51 ` [PATCH v3 3/4] perf inject/aslr: Add aslr tool to remap/obfuscate virtual addresses Ian Rogers
2026-05-04 4:51 ` sashiko-bot
2026-05-04 3:51 ` [PATCH v3 4/4] perf test: Add inject ASLR test Ian Rogers
2026-05-04 5:02 ` sashiko-bot
2026-05-04 7:29 ` [PATCH v4 0/4] perf tools: Add inject --aslr feature and prerequisite robustness fixes Ian Rogers
2026-05-04 7:29 ` [PATCH v4 1/4] perf sched: Add missing mmap2 handler in timehist Ian Rogers
2026-05-04 7:29 ` [PATCH v4 2/4] perf tool: Fix missing schedstat delegates and dont_split_sample_group in delegate_tool Ian Rogers
2026-05-04 7:29 ` [PATCH v4 3/4] perf inject/aslr: Add aslr tool to remap/obfuscate virtual addresses Ian Rogers
2026-05-04 8:39 ` sashiko-bot
2026-05-04 7:29 ` [PATCH v4 4/4] perf test: Add inject ASLR test Ian Rogers
2026-05-04 8:48 ` sashiko-bot
2026-05-04 8:23 ` [PATCH v4 0/4] perf tools: Add inject --aslr feature and prerequisite robustness fixes Ian Rogers
2026-05-06 0:45 ` [PATCH v5 0/5] " Ian Rogers
2026-05-06 0:45 ` [PATCH v5 1/5] perf sched: Add missing mmap2 handler in timehist Ian Rogers
2026-05-06 13:22 ` Arnaldo Carvalho de Melo
2026-05-06 16:16 ` Ian Rogers
2026-05-06 0:45 ` [PATCH v5 2/5] perf tool: Fix missing schedstat delegates and dont_split_sample_group in delegate_tool Ian Rogers
2026-05-06 0:45 ` [PATCH v5 3/5] perf symbols: Fix map removal sequence inside dso__process_kernel_symbol() Ian Rogers
2026-05-06 1:45 ` sashiko-bot
2026-05-06 0:45 ` [PATCH v5 4/5] perf inject/aslr: Add aslr tool to remap/obfuscate virtual addresses Ian Rogers
2026-05-06 2:40 ` sashiko-bot
2026-05-06 18:52 ` Namhyung Kim
2026-05-06 20:01 ` Ian Rogers
2026-05-06 0:45 ` [PATCH v5 5/5] perf test: Add inject ASLR test Ian Rogers
2026-05-07 15:58 ` James Clark
2026-05-07 16:17 ` Ian Rogers
2026-05-08 10:42 ` James Clark
2026-05-08 10:49 ` James Clark
2026-05-08 8:27 ` [PATCH v6 0/6] perf tools: Add inject --aslr feature and prerequisite robustness fixes Ian Rogers
2026-05-08 8:27 ` [PATCH v6 1/6] perf sched: Add missing mmap2 handler in timehist Ian Rogers
2026-05-08 8:27 ` [PATCH v6 2/6] perf tool: Missing delegate_tool schedstat delegates and dont_split_sample_group Ian Rogers
2026-05-08 8:27 ` [PATCH v6 3/6] perf maps: Add maps__mutate_mapping Ian Rogers
2026-05-08 10:57 ` James Clark
2026-05-08 20:37 ` sashiko-bot
2026-05-11 7:07 ` Namhyung Kim
2026-05-08 8:27 ` [PATCH v6 4/6] perf inject/aslr: Add aslr tool to remap/obfuscate virtual addresses Ian Rogers
2026-05-08 21:22 ` sashiko-bot
2026-05-11 7:32 ` Namhyung Kim
2026-05-08 8:27 ` [PATCH v6 5/6] perf test: Add inject ASLR test Ian Rogers
2026-05-08 13:29 ` James Clark
2026-05-08 14:29 ` James Clark
2026-05-11 7:34 ` Namhyung Kim
2026-05-08 8:27 ` [PATCH v6 6/6] perf aslr: Strip sample registers Ian Rogers
2026-05-08 21:49 ` 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=20260508214911.ADD7AC2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=irogers@google.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko@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