LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Andrea Parri <andrea.parri@amarulasolutions.com>
Cc: Jann Horn <jannh@google.com>, Oleg Nesterov <oleg@redhat.com>,
	"Eric W . Biederman" <ebiederm@xmission.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Kees Cook <keescook@chromium.org>,
	David Howells <dhowells@redhat.com>,
	kernel list <linux-kernel@vger.kernel.org>,
	Will Deacon <will.deacon@arm.com>,
	"Paul E. McKenney" <paulmck@linux.ibm.com>
Subject: Re: [PATCH] ptrace: restore smp_rmb() in __ptrace_may_access()
Date: Fri, 31 May 2019 11:08:01 +0200	[thread overview]
Message-ID: <20190531090801.GM2677@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20190530103405.GA6392@andrea>

On Thu, May 30, 2019 at 12:34:05PM +0200, Andrea Parri wrote:
> On Wed, May 29, 2019 at 07:38:46PM +0200, Jann Horn wrote:
> > On Wed, May 29, 2019 at 6:21 PM Oleg Nesterov <oleg@redhat.com> wrote:

> > > (I am wondering if smp_acquire__after_ctrl_dep() could be used instead, just to
> > >  make this code look more confusing)
> > 
> > Uuh, I had no idea that that barrier type exists. The helper isn't
> > even explicitly mentioned in Documentation/memory-barriers.rst. I
> > don't really want to use dark magic in the middle of ptrace access
> > logic...

Yeah, it's sorta not documented on purpose. It's too easy to get wrong
and we've only used it inside a number of more convenient primitives as
an optimzation.

I suppose we could add it to the section on control dependencies; just
to scare more people :-)

> > Anyway, looking at it, I think smp_acquire__after_ctrl_dep() doesn't
> > make sense here; quoting the documentation: "A load-load control
> > dependency requires a full read memory barrier, not simply a data
> > dependency barrier to make it work correctly". IIUC
> > smp_acquire__after_ctrl_dep() is for cases in which you would
> > otherwise need a full memory barrier - smp_mb() - and you want to be
> > able to reduce it to a read barrier.
> 
> It is supposed to be used when you want an ACQUIRE but you only have a
> control dependency (so you "augment the dependency" with this barrier).
> 
> FWIW, I do agree on the "dark magic"..., and I'd strongly recommend to
> not use this barrier (or, at least, to use it with high suspicion).

Right, so the purpose of the barrier is to upgrade a LOAD->STORE order
(as provided by the ctrl-dep) to a LOAD->{LOAD,STORE} order as would be
provided by load-acquire.


  reply	other threads:[~2019-05-31  9:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29 11:31 Jann Horn
2019-05-29 15:59 ` Eric W. Biederman
2019-05-29 16:01   ` Jann Horn
2019-05-29 16:21 ` Oleg Nesterov
2019-05-29 17:38   ` Jann Horn
2019-05-30  1:41     ` Eric W. Biederman
2019-05-31 15:04       ` Jann Horn
2019-05-30 10:34     ` Andrea Parri
2019-05-31  9:08       ` Peter Zijlstra [this message]
2019-05-30 12:05     ` Oleg Nesterov
2019-05-31  9:12       ` Peter Zijlstra
2019-05-31  9:55         ` Oleg Nesterov
2019-05-29 21:02   ` Jann Horn
2019-05-29 18:55 ` Kees Cook
2019-05-30 12:34 ` Oleg Nesterov
2019-05-31 11:56   ` Jann Horn
2019-05-31 13:35     ` Oleg Nesterov
2019-05-31 19:37       ` Jann Horn

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=20190531090801.GM2677@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrea.parri@amarulasolutions.com \
    --cc=dhowells@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=jannh@google.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=paulmck@linux.ibm.com \
    --cc=will.deacon@arm.com \
    --subject='Re: [PATCH] ptrace: restore smp_rmb() in __ptrace_may_access()' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).