From: sashiko-bot@kernel.org
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 2/2] uprobes: Skip remove_breakpoint() if UPROBE_COPY_INSN is not set
Date: Thu, 03 Dec 2026 10:17:15 +0000 [thread overview]
Message-ID: <sashiko-outbox-247557@kernel.org> (raw)
In-Reply-To: <179629194562.2709886.5573348043761281153.stgit@mhiramat.c.googlers.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] uprobes: early return in remove_breakpoint() skips
MMF_RECALC_UPROBES
--
commit 7922d016707ed1ec398765711ff02f36bfd6af90
Author: Masami Hiramatsu (Google) <mhiramat@kernel.org>
uprobes: Skip remove_breakpoint() if UPROBE_COPY_INSN is not set
This commit makes remove_breakpoint() return early if UPROBE_COPY_INSN is
not set in uprobe->flags, and adds an smp_rmb() pairing with
prepare_uprobe() before set_orig_insn() reads uprobe->arch.
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index e850865045b21..7f0515c9dc327 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
[ ... ]
> @@ -1194,6 +1197,19 @@ static int remove_breakpoint(struct uprobe *uprobe, struct vm_area_struct *vma,
> {
> struct mm_struct *mm = vma->vm_mm;
>
> + /* No breakpoint was ever installed if prepare_uprobe() never succeeded */
> + if (!test_bit(UPROBE_COPY_INSN, &uprobe->flags))
> + return 0;
> +
> + /*
> + * Pairs with the smp_wmb() in prepare_uprobe().
> + *
> + * Guarantees that if we see the UPROBE_COPY_INSN bit set, then
> + * we must also see the stores to &uprobe->arch before
> + * set_orig_insn() reads them.
> + */
> + smp_rmb();
> +
> mm_flags_set(MMF_RECALC_UPROBES, mm);
> return set_orig_insn(&uprobe->arch, vma, vaddr);
> }
[Severity: Medium]
Can returning early here leave MMF_HAS_UPROBES permanently set on mm?
Suppose a process has two uprobes on the same mapped file: U1 is installed
(setting MMF_HAS_UPROBES), and U2 has a consumer filter that rejects this
process so U2 sits in uprobes_tree with UPROBE_COPY_INSN unset.
When U1 is unregistered, remove_breakpoint() sets MMF_RECALC_UPROBES. If
the process then hits a non-uprobe trap, find_active_uprobe_rcu() clears
MMF_RECALC_UPROBES and calls mmf_recalc_uprobes(), which finds U2 via
vma_has_uprobes() and leaves MMF_HAS_UPROBES set.
When U2 is later unregistered, remove_breakpoint() now returns 0 without
setting MMF_RECALC_UPROBES. Once U2 is gone from uprobes_tree, even
uprobe_munmap() will not set it, leaving MMF_HAS_UPROBES stuck so later
non-uprobe traps keep taking the find_active_uprobe_rcu() slow path.
Calling mm_flags_set(MMF_RECALC_UPROBES, mm) before checking
UPROBE_COPY_INSN would avoid this regression while still skipping
set_orig_insn().
--
Sashiko AI review · https://sashiko.dev/#/patchset/179629192497.2709886.2379669650835098449.stgit@mhiramat.c.googlers.com?part=2
next prev parent reply other threads:[~2026-12-03 10:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 9:58 [PATCH 0/2] uprobes: Fix UPROBE_COPY_INSN ordering and breakpoint removal Masami Hiramatsu (Google)
2026-12-03 9:58 ` [PATCH 1/2] uprobes: Add missing read memory barrier in prepare_uprobe() Masami Hiramatsu (Google)
2026-12-03 9:59 ` [PATCH 2/2] uprobes: Skip remove_breakpoint() if UPROBE_COPY_INSN is not set Masami Hiramatsu (Google)
2026-12-03 10:17 ` sashiko-bot [this message]
2026-12-03 10:17 ` [PATCH 0/2] uprobes: Fix UPROBE_COPY_INSN ordering and breakpoint removal 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=sashiko-outbox-247557@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@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