From: sashiko-bot@kernel.org
To: "Andi Kleen" <ak@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [RFC v1 16/19] ptwrite uprobes / perf tools pt: Improve FUP error handling for ptwrite
Date: Mon, 31 Aug 2026 21:19:37 +0000 [thread overview]
Message-ID: <20260831211938.27A291F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831150651.1134594-17-ak@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Incorrect ptwrite IP reporting and failure to prevent trace abort in full instruction tracing mode.
- [Medium] Bypassing `intel_pt_fup_event()` causes incomplete manual state reconstruction, leaking instruction metadata and asynchronous FUP flags.
--
commit f901af3d0d6f6651e120a5aaaf5502b7aa3f6612
Author: Andi Kleen <ak@kernel.org>
ptwrite uprobes / perf tools pt: Improve FUP error handling for ptwrite
Special case the decoder to handle ptwrite FUPs targeting unmapped code
like uprobe stubs. When the decoder can't resolve the instruction page,
report the ptwrite with its IP instead of erroring out and failing the walk.
> diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
> index e733f6b1f7ac5..bd31d65dbe035 100644
> --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
> +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
> @@ -1440,8 +1440,29 @@ static int intel_pt_walk_fup(struct intel_pt_decoder *decoder)
> return -EAGAIN;
> }
> decoder->set_fup_tx_flags = false;
> - if (err)
> + if (err) {
> + /*
> + * A ptwrite's FUP can target an address whose
> + * instruction cannot be resolved (e.g. the
> + * [uprobes-ptwrite] stub is an anonymous special
> + * mapping invisible to the machine). The FUP is
> + * still the ptwrite's IP: report it rather than
> + * failing the whole walk.
> + */
> + if (decoder->set_fup_ptw) {
> + decoder->set_fup_ptw = false;
> + decoder->pkt_state = INTEL_PT_STATE_IN_SYNC;
> + decoder->state.type &= ~INTEL_PT_BRANCH;
> + decoder->state.type |= INTEL_PT_PTW;
[Severity: Medium]
Will bypassing intel_pt_fup_event() here leak instruction metadata and
asynchronous FUP flags?
Because intel_pt_walk_insn() returned an error early, decoder->state.insn_op
and insn_len retain the metadata from the last successfully decoded
instruction. By skipping intel_pt_fup_event() which usually clears these
fields and handles asynchronous flags, could stale instruction op/len and
pending event flags be incorrectly attributed to subsequent events?
> + decoder->state.flags |= INTEL_PT_FUP_IP;
> + decoder->state.from_ip = decoder->ip;
[Severity: High]
Does this code assign the wrong IP for the PTWRITE event and fail to prevent
the trace abort it intends to fix?
When intel_pt_walk_insn() encounters an unmapped region like the uprobe stub,
it returns an error without advancing decoder->ip. The true PTWRITE IP from
the hardware FUP packet is passed as the ip parameter (from
decoder->last_ip) to intel_pt_walk_insn().
Assigning decoder->state.from_ip = decoder->ip instead of using the ip
parameter attributes the event to the stuck failure address. Additionally,
because decoder->ip is never advanced out of the unmapped region, subsequent
packets could trigger functions like intel_pt_walk_tip() to call
intel_pt_walk_insn(..., 0) starting from the same stuck decoder->ip, failing
again and aborting the trace.
> + decoder->state.to_ip = 0;
> + decoder->state.ptw_payload =
> + decoder->fup_ptw_payload;
> + return 0;
> + }
> return err;
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831150651.1134594-1-ak@kernel.org?part=16
next prev parent reply other threads:[~2026-08-31 21:19 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 15:04 [RFC] ptwrite uprobes Andi Kleen
2026-08-31 15:04 ` [RFC v1 01/19] uprobes: guard trace cleanup against error pointers Andi Kleen
2026-08-31 18:15 ` sashiko-bot
2026-09-01 0:49 ` Masami Hiramatsu
2026-08-31 15:04 ` [RFC v1 02/19] uprobes: Correctly reject anonymous VMAs for breakpoint installation Andi Kleen
2026-08-31 18:29 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 03/19] uprobes: Print warning for missing breakpoint install Andi Kleen
2026-08-31 18:42 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 04/19] ptwrite uprobes: Add infrastructure for ptwrite uprobes Andi Kleen
2026-08-31 18:55 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 05/19] ptwrite uprobes: Add minimal low level support for x86 Andi Kleen
2026-08-31 19:11 ` sashiko-bot
2026-09-02 16:35 ` Lorenzo Stoakes (ARM)
2026-08-31 15:04 ` [RFC v1 06/19] ptwrite uprobes: Add a sample module to exercise interface Andi Kleen
2026-08-31 19:19 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 07/19] ptwrite uprobes: Add support to tracing infrastructure Andi Kleen
2026-08-31 19:31 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 08/19] ptwrite uprobes / x86: Add a user fault notifier chain Andi Kleen
2026-08-31 19:38 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 09/19] ptwrite uprobes: Factor file-backed instruction reads Andi Kleen
2026-08-31 19:45 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 10/19] ptwrite uprobes: Minimal memory references and fault handling Andi Kleen
2026-08-31 19:59 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 11/19] ptwrite uprobes: Add multinop support Andi Kleen
2026-08-31 20:09 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 12/19] ptwrite uprobes: Add pacing to the probes Andi Kleen
2026-08-31 20:19 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 13/19] ptwrite uprobes: Support instruction puning Andi Kleen
2026-08-31 20:39 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 14/19] ptwrite uprobes: Use atomic patching for multinop sites Andi Kleen
2026-08-31 21:08 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 15/19] ptwrite uprobes: Add a tutorial and overview documentation Andi Kleen
2026-08-31 21:10 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 16/19] ptwrite uprobes / perf tools pt: Improve FUP error handling for ptwrite Andi Kleen
2026-08-31 21:19 ` sashiko-bot [this message]
2026-08-31 15:04 ` [RFC v1 17/19] ptwrite uprobes / perf tools probe: Add support of ptwrite probes Andi Kleen
2026-08-31 21:32 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 18/19] ptwrite uprobes / perf tools script: Add ptwrite uprobes decoder Andi Kleen
2026-08-31 21:39 ` sashiko-bot
2026-08-31 15:04 ` [RFC v1 19/19] ptwrite uprobes: Add self tests Andi Kleen
2026-08-31 21:47 ` 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=20260831211938.27A291F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ak@kernel.org \
--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