Re: [PATCH 1/2] uprobes: Add missing read memory barrier in prepare_uprobe()
From: Masami Hiramatsu (Google)
Date: Thu Dec 03 2026 - 21:44:36 EST
On Thu, 3 Dec 2026 12:19:45 +0100, Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> On 12/03, Masami Hiramatsu (Google) wrote:
> >
> > --- a/kernel/events/uprobes.c
> > +++ b/kernel/events/uprobes.c
[...]
> > - smp_wmb(); /* pairs with the smp_rmb() in handle_swbp() */
> > + /* Pairs with the smp_rmb() in prepare_uprobe() and handle_swbp() */
> > + smp_wmb();
> > set_bit(UPROBE_COPY_INSN, &uprobe->flags);
>
> Acked-by: Oleg Nesterov <oleg@xxxxxxxxxx>
Thanks for the Ack!
>
> But I guess we could use test_bit_acquire(UPROBE_COPY_INSN) and
> smp_mb__before_atomic() before set_bit(UPROBE_COPY_INSN) ?
Yes, that makes this much cleaner. It avoids an explicit smp_rmb() on the
fast path (and on x86 smp_mb__before_atomic() compiles away since set_bit()
is already ordered).
I'll update prepare_uprobe() and handle_swbp() to use test_bit_acquire()
paired with smp_mb__before_atomic() in v2.
Thank you,
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>