From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v7 2/4] perf inject/aslr: Add aslr tool to remap/obfuscate virtual addresses
Date: Tue, 19 May 2026 09:14:11 +0000 [thread overview]
Message-ID: <20260519091411.BB99BC2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260519080824.3329601-3-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Modifying `evsel->core.attr.sample_type` upfront corrupts the input event parser, causing misaligned reads of raw payload data.
- [High] Ineffective deadlock mitigation due to pre-loading kernel maps into the wrong `machines` struct and premature guest evaluation.
- [High] `aslr_tool__process_ksymbol` truncates ksymbol addresses to the base address of their containing map.
--
commit 9d45b9cad9df39407d7e9e5d06994ca1d17cd797
Author: Ian Rogers <irogers@google.com>
perf inject/aslr: Add aslr tool to remap/obfuscate virtual addresses
This commit introduces an ASLR tool for perf inject that remaps virtual
addresses to prevent leaking address space layouts when sharing perf.data
files. It also attempts to eliminate lazy-loading deadlocks by preloading
kernel and module maps before processing events.
> diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
> index a2493f1097df9..8fe924e730a16 100644
> --- a/tools/perf/builtin-inject.c
> +++ b/tools/perf/builtin-inject.c
[ ... ]
> @@ -2267,6 +2269,56 @@ static int output_fd(struct perf_inject *inject)
[ ... ]
> +/*
> + * Scans and force-loads all registered host and guest machine kernel and
> + * module maps up front before event processing starts.
> + */
> +static int perf_inject__load_kernel_maps(struct perf_inject *inject)
> +{
> + struct machine *machine;
> + struct rb_node *nd;
> + int err = 0;
> +
> + /* Load host kernel maps up front */
> + if (machine__load_kernel_maps(&inject->session->machines.host) < 0)
> + err = -1;
> +
> + /* Load all guest machines kernel maps up front */
> + for (nd = rb_first_cached(&inject->session->machines.guests); nd; nd = rb_next(nd)) {
> + machine = rb_entry(nd, struct machine, rb_node);
> + if (machine__load_kernel_maps(machine) < 0)
> + err = -1;
> + }
> +
> + return err;
> +}
Does this preload the kernel maps into the correct machines collection?
It looks like this loads into inject->session->machines, but the ASLR tool
uses its own isolated aslr->machines collection which starts empty. Because
the preloaded maps are not available to the ASLR tool, will kernel maps still
be lazy-loaded dynamically during runtime event processing?
Also, since this is called before perf_session__process_events(), are there
any guest machines discovered from the event stream yet to iterate over?
[ ... ]
> @@ -2689,18 +2758,38 @@ int cmd_inject(int argc, const char **argv)
[ ... ]
> + if (inject.aslr) {
> + struct evsel *evsel;
> +
> + evlist__for_each_entry(inject.session->evlist, evsel) {
> + evsel->core.attr.sample_type &= ASLR_SUPPORTED_SAMPLE_TYPE;
> +
> + if (evsel->core.attr.type == PERF_TYPE_BREAKPOINT)
> + evsel->core.attr.bp_addr = 0;
> + }
> + }
Does modifying the sample_type upfront cause the input event parser to
misread the physical perf.data file?
The input file was recorded with the original sample_type, so its payloads
still contain the stripped fields. In aslr_tool__process_sample(), when it
checks the masked sample_type:
sample_type = evsel->core.attr.sample_type;
...
if (sample_type & PERF_SAMPLE_REGS_USER) { ... }
Won't it fail to advance the input array index over the register payload,
causing subsequent checks to mistakenly read the leftover register payload
data as stack sizes or lengths?
> diff --git a/tools/perf/util/aslr.c b/tools/perf/util/aslr.c
> new file mode 100644
> index 0000000000000..d0b1b33377fd2
> --- /dev/null
> +++ b/tools/perf/util/aslr.c
[ ... ]
> +static int aslr_tool__process_ksymbol(const struct perf_tool *tool,
> + union perf_event *event,
> + struct perf_sample *sample,
> + struct machine *machine)
> +{
[ ... ]
> + /* Remaps the ksymbol.start */
> + new_event->ksymbol.addr = aslr_tool__findnew_mapping(aslr, thread,
> + PERF_RECORD_MISC_KERNEL,
> + event->ksymbol.addr,
> + event->ksymbol.len,
> + /*pgoff=*/0);
> +
> + err = delegate->ksymbol(delegate, new_event, sample, machine);
> + thread__put(thread);
> + return err;
> +}
Could this truncate ksymbol addresses?
The aslr_tool__findnew_mapping() function appears to return the remapped base
address of the entire map when an address falls into an existing map, but it
does not seem to add the symbol's internal offset.
Will this cause ksymbols inside an existing kernel map to be clustered at the
exact start address of the mapping in the output trace?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260519080824.3329601-1-irogers@google.com?part=2
next prev parent reply other threads:[~2026-05-19 9:14 UTC|newest]
Thread overview: 70+ 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
2026-05-19 8:08 ` [PATCH v7 0/4] perf tools: Add inject --aslr feature, early maps loading, and decoupling fixes Ian Rogers
2026-05-19 8:08 ` [PATCH v7 1/4] perf maps: Add maps__mutate_mapping Ian Rogers
2026-05-19 8:38 ` sashiko-bot
2026-05-19 8:08 ` [PATCH v7 2/4] perf inject/aslr: Add aslr tool to remap/obfuscate virtual addresses Ian Rogers
2026-05-19 9:14 ` sashiko-bot [this message]
2026-05-19 8:08 ` [PATCH v7 3/4] perf test: Add inject ASLR test Ian Rogers
2026-05-19 8:08 ` [PATCH v7 4/4] perf aslr: Strip sample registers Ian Rogers
2026-05-19 9:55 ` sashiko-bot
2026-05-20 6:30 ` [PATCH v8 0/4] perf tools: Add inject --aslr feature, early maps loading, and decoupling fixes Ian Rogers
2026-05-20 6:30 ` [PATCH v8 1/4] perf maps: Add maps__mutate_mapping Ian Rogers
2026-05-20 7:06 ` sashiko-bot
2026-05-20 6:30 ` [PATCH v8 2/4] perf inject/aslr: Add aslr tool to remap/obfuscate virtual addresses Ian Rogers
2026-05-20 7:50 ` sashiko-bot
2026-05-20 6:30 ` [PATCH v8 3/4] perf test: Add inject ASLR test Ian Rogers
2026-05-20 8:02 ` sashiko-bot
2026-05-20 6:30 ` [PATCH v8 4/4] perf aslr: Strip sample registers Ian Rogers
2026-05-20 8:41 ` sashiko-bot
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=20260519091411.BB99BC2BCB3@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=irogers@google.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