Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v9 5/5] perf aslr: Strip sample registers
Date: Thu, 04 Jun 2026 17:45:18 +0000	[thread overview]
Message-ID: <20260604174518.7E1B51F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260604172850.683329-6-irogers@google.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] Allocating `stripped_event` using unvalidated `event->header.size` and unconditionally writing to `sample_regs_user` and `sample_regs_intr` causes a severe heap buffer overflow.
- [High] Missing register stripping in the `itrace`-enabled path of `perf_event__repipe_attr` corrupts the trace output.
--

commit 5f1dabd94a15919e76927871536447a8782dba24
Author: Ian Rogers <irogers@google.com>

perf aslr: Strip sample registers

Refactor the ASLR tool to strip out only the register dump payload
by masking out the relevant perf_event_attr fields when the delegated
tool is handling the data. struct aslr_evsel_priv maintains the
original perf_event_attr values and is looked up via the evsel_orig_attrs
hashmap.

> diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
> index a9f0a3901e7bc..e0f59ef8b97b2 100644
> --- a/tools/perf/builtin-inject.c
> +++ b/tools/perf/builtin-inject.c
> @@ -253,6 +253,8 @@ static int perf_event__repipe_attr(const struct perf_tool *tool,
>  				return -ENOMEM;
>  			memcpy(stripped_event, event, event->header.size);
>  			stripped_event->attr.attr.sample_type &= ASLR_SUPPORTED_SAMPLE_TYPE;
> +			stripped_event->attr.attr.sample_regs_user = 0;
> +			stripped_event->attr.attr.sample_regs_intr = 0;

[Severity: Critical]
Can this write out of bounds and corrupt the heap?

In perf_event__repipe_attr(), stripped_event is allocated using
event->header.size. For older perf.data formats (like PERF_ATTR_SIZE_VER0),
the size can be as small as 72 bytes.

However, sample_regs_user and sample_regs_intr are at offsets 88 and 104 in
the perf_event_attr structure. Writing to these fields unconditionally on a
72-byte allocation will corrupt the heap when processing older traces.

[Severity: High]
Also in perf_event__repipe_attr(), when itrace_synth_opts.set is true,
should the register bits and masks be cleared from the synthesized attr?

When --itrace and --aslr are used together in pipe mode, the code branches to
the itrace_synth_opts.set path in perf_event__repipe_attr():

perf_event__repipe_attr() {
    ...
    if (!inject->itrace_synth_opts.set) {
        /* registers are stripped in this branch */
    }
    ...
    attr.sample_type &= ~PERF_SAMPLE_AUX;
    if (inject->aslr)
        attr.sample_type &= ASLR_SUPPORTED_SAMPLE_TYPE;
    /* register clearing is missing here */
    ...
    perf_event__synthesize_attr(...)
}

This patch strips the repiped samples of their register payloads via
aslr_tool__process_sample(), but the itrace path above leaves the register
flags in the attr event.

This mismatch between the attr event and the payload can corrupt the output
pipe trace and cause parsers to fail.

>  			if (stripped_event->attr.attr.type == PERF_TYPE_BREAKPOINT)
>  				stripped_event->attr.attr.bp_addr = 0;

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260604172850.683329-1-irogers@google.com?part=5

      reply	other threads:[~2026-06-04 17:45 UTC|newest]

Thread overview: 82+ 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
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-23 14:44                 ` kernel test robot
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
2026-06-04 17:28               ` [PATCH v9 0/5] perf tools: Add inject --aslr feature, early maps loading, and decoupling fixes Ian Rogers
2026-06-04 17:28                 ` [PATCH v9 1/5] perf maps: Add maps__mutate_mapping Ian Rogers
2026-06-04 17:46                   ` sashiko-bot
2026-06-04 17:28                 ` [PATCH v9 2/5] perf inject/aslr: Add ASLR tool infrastructure and MMAP tracking Ian Rogers
2026-06-04 17:45                   ` sashiko-bot
2026-06-04 17:28                 ` [PATCH v9 3/5] perf inject/aslr: Implement sample address remapping Ian Rogers
2026-06-04 17:45                   ` sashiko-bot
2026-06-04 17:28                 ` [PATCH v9 4/5] perf test: Add inject ASLR test Ian Rogers
2026-06-04 17:40                   ` sashiko-bot
2026-06-04 17:28                 ` [PATCH v9 5/5] perf aslr: Strip sample registers Ian Rogers
2026-06-04 17:45                   ` 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=20260604174518.7E1B51F00893@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