From: Peter Zijlstra <peterz@infradead.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 0/2] uprobes: Fix UPROBE_COPY_INSN ordering and breakpoint removal
Date: Sat, 5 Dec 2026 01:01:23 +0100 [thread overview]
Message-ID: <20261205000123.GQ2883950@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <179636410109.1272823.4239028800411906863.stgit@mhiramat.c.googlers.com>
On Fri, Dec 04, 2026 at 03:01:41PM +0900, Masami Hiramatsu (Google) wrote:
> Hi,
>
> This is v2 of the series fixing two bugs around UPROBE_COPY_INSN handling
> in kernel/events/uprobes.c (both reported by Sashiko).
>
> The previous version is here:
> https://lore.kernel.org/all/179629192497.2709886.2379669650835098449.stgit@mhiramat.c.googlers.com/
>
> Changes in v2:
> - [1/2] Switch from test_bit() + smp_rmb() / smp_wmb() to
> test_bit_acquire() paired with smp_mb__before_atomic() + set_bit()
> in prepare_uprobe() and handle_swbp(), as suggested by Oleg.
> - [2/2] Keep mm_flags_set(MMF_RECALC_UPROBES, mm) before checking
> UPROBE_COPY_INSN so filtered-out uprobes do not leave MMF_HAS_UPROBES
> stuck on mm (reported by Sashiko AI review), and use
> test_bit_acquire() as suggested by Oleg.
>
> 1. prepare_uprobe() uses double-checked locking around UPROBE_COPY_INSN,
> with a memory barrier before set_bit(UPROBE_COPY_INSN, &uprobe->flags),
> but the lockless fast path returns 0 without a paired acquire barrier.
> On weakly-ordered architectures, a concurrent caller can observe
> UPROBE_COPY_INSN set while reading stale uprobe->arch fields (such as
> auprobe->bpinsn in ARM's set_swbp()). Patch 1 uses test_bit_acquire()
> paired with smp_mb__before_atomic() + set_bit() in prepare_uprobe()
> and converts handle_swbp() for consistency.
>
> 2. remove_breakpoint() unconditionally calls set_orig_insn(&uprobe->arch,
> ...) without checking UPROBE_COPY_INSN. If prepare_uprobe() previously
> failed or never ran, uprobe->arch.insn remains zero-initialized or
> unvalidated, and error cleanup, unregistration, or
> uprobe_apply(..., false) can overwrite an existing third-party
> software breakpoint (such as GDB) with zeroes. Patch 2 sets
> MMF_RECALC_UPROBES first and then returns early if
> test_bit_acquire(UPROBE_COPY_INSN, &uprobe->flags) is false.
>
> Both patches are based on v7.4-rc5.
>
> Thank you,
>
> Masami Hiramatsu (Google) (2):
> uprobes: Add missing read memory barrier in prepare_uprobe()
> uprobes: Skip remove_breakpoint() if UPROBE_COPY_INSN is not set
>
> kernel/events/uprobes.c | 34 ++++++++++++++++++++++++----------
> 1 file changed, 24 insertions(+), 10 deletions(-)
Thanks!
prev parent reply other threads:[~2026-12-05 0:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 6:01 [PATCH v2 0/2] uprobes: Fix UPROBE_COPY_INSN ordering and breakpoint removal Masami Hiramatsu (Google)
2026-12-04 6:01 ` [PATCH v2 1/2] uprobes: Add missing read memory barrier in prepare_uprobe() Masami Hiramatsu (Google)
2026-12-04 6:02 ` [PATCH v2 2/2] uprobes: Skip remove_breakpoint() if UPROBE_COPY_INSN is not set Masami Hiramatsu (Google)
2026-12-05 0:01 ` Peter Zijlstra [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=20261205000123.GQ2883950@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=oleg@redhat.com \
/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