public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Parri <andrea.parri@amarulasolutions.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [Question] smp_wmb() in prepare_uprobe()
Date: Thu, 22 Nov 2018 16:45:27 +0100	[thread overview]
Message-ID: <20181122154526.GA14616@andrea> (raw)
In-Reply-To: <20181122150524.GF28270@redhat.com>

On Thu, Nov 22, 2018 at 04:05:24PM +0100, Oleg Nesterov wrote:
> On 11/22, Andrea Parri wrote:
> >
> > > See 142b18ddc81439acda4bc4231b291e99fe67d507 ("uprobes: Fix handle_swbp()
> > > vs unregister() + register() race") and the comment above this rmb().
> >
> > Mmh..., at first glance, this suggests me that the above set_bit() and
> > test_bit() to/from uprobe->flags are among these memory accesses.  But
> > this doesn't make sense to me: these accesses do not "alternate" (i.e.,
> > they both appear after the corresponding barrier..); instead I'd expect
> > something like (on top of the above diff):
> >
> > diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> > index 2d29977522017..a75b9a08dee54 100644
> > --- a/kernel/events/uprobes.c
> > +++ b/kernel/events/uprobes.c
> > @@ -2178,10 +2178,18 @@ static void handle_swbp(struct pt_regs *regs)
> >  	 * After we hit the bp, _unregister + _register can install the
> >  	 * new and not-yet-analyzed uprobe at the same address, restart.
> >  	 */
> > -	smp_rmb(); /* pairs with the smp_wmb() in prepare_uprobe() */
> >  	if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags)))
> >  		goto out;
> >
> > +	/*
> > +	 * Pairs with the smp_wmb() in prepare_uprobe().
> > +	 *
> > +	 * Guarantees that if we see the UPROBE_COPY_INSN bit set, then
> > +	 * we must (can) also see the stores to &uprobe->arch performed
> > +	 * by prepare_uprobe() (say).
> > +	 */
> > +	smp_rmb();
> 
> OOPS, you are right! Thanks.

Thank you for the clarification; I'll send a patch with the fix shortly.

  Andrea


> 
> Oleg.
> 

      reply	other threads:[~2018-11-22 15:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21 22:41 [Question] smp_wmb() in prepare_uprobe() Andrea Parri
2018-11-22 12:36 ` Oleg Nesterov
2018-11-22 13:44   ` Andrea Parri
2018-11-22 15:05     ` Oleg Nesterov
2018-11-22 15:45       ` Andrea Parri [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=20181122154526.GA14616@andrea \
    --to=andrea.parri@amarulasolutions.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    /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