LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Kees Cook <keescook@chromium.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	tcharding <me@tobin.cc>
Subject: Re: [PATCH] vsprintf: Fix memory barriers of ptr_key to have_filed_random_ptr_key
Date: Wed, 23 May 2018 12:40:37 +0200	[thread overview]
Message-ID: <20180523104037.GD15312@amd> (raw)
In-Reply-To: <20180515145744.3bdcbbe9@gandalf.local.home>

[-- Attachment #1: Type: text/plain, Size: 1684 bytes --]

On Tue 2018-05-15 14:57:44, Steven Rostedt wrote:
> On Tue, 15 May 2018 09:55:13 -0700
> Linus Torvalds <torvalds@linux-foundation.org> wrote:
> 
> > On Tue, May 15, 2018 at 7:06 AM Steven Rostedt <rostedt@goodmis.org> wrote:
> > > -       smp_mb();
> > > +       smp_wmb();
> > >          WRITE_ONCE(have_filled_random_ptr_key, true);  
> > 
> > 
> > > +       /* Read ptr_key after reading have_filled_random_ptr_key */
> > > +       smp_rmb();
> > > +
> > >   #ifdef CONFIG_64BIT
> > >          hashval = (unsigned long)siphash_1u64((u64)ptr, &ptr_key);  
> > 
> > Hmm. smp_wmb/rmb are basically free on x86, but on some architectures
> > smp_rmb() in particular can be pretty expensive.
> > 
> > So when you have a "handoff" situation like this, it's _probably_ better to
> > use use "smp_store_release()" and "smp_load_acquire()". To some degree that
> > might also be better for documentation purposes, because that's exactly the
> > "release-acquire" pattern.
> > 
> > That said, I'm not convinced this really matters all that much for a
> > boot-time flag like this. The race is pretty theoretical.
> >
> 
> I was thinking the same. But since the smp_mb() is there, then it
> should be correct, which it currently isn't.
> 
> We could change this to a static key, and enable it after we set up
> the ptr_key. That would be a one time change at boot up, wont have
> races, and have no overhead.

OTOH... fixing theoretical races is nice, but probably should not go
to stable?
								Pavel
								
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  parent reply	other threads:[~2018-05-23 10:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-15 14:05 Steven Rostedt
2018-05-15 16:55 ` Linus Torvalds
2018-05-15 18:57   ` Steven Rostedt
2018-05-15 19:03     ` Linus Torvalds
2018-05-15 20:10       ` Steven Rostedt
2018-05-15 22:31         ` Linus Torvalds
2018-05-15 22:41           ` Steven Rostedt
2018-05-15 23:00             ` Steven Rostedt
2018-05-15 23:10               ` Linus Torvalds
2018-05-23 10:40     ` Pavel Machek [this message]
2018-05-24 18:44       ` Steven Rostedt

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=20180523104037.GD15312@amd \
    --to=pavel@ucw.cz \
    --cc=akpm@linux-foundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@tobin.cc \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.org \
    --subject='Re: [PATCH] vsprintf: Fix memory barriers of ptr_key to have_filed_random_ptr_key' \
    /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).