[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFyBHRmXLo07f_7qt7szaDvppMStfX5Sq9Df6mZSy+qYvA@mail.gmail.com>
Date: Tue, 15 May 2018 09:55:13 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>,
Kees Cook <keescook@...omium.org>,
Andrew Morton <akpm@...ux-foundation.org>,
tcharding <me@...in.cc>
Subject: Re: [PATCH] vsprintf: Fix memory barriers of ptr_key to have_filed_random_ptr_key
On Tue, May 15, 2018 at 7:06 AM Steven Rostedt <rostedt@...dmis.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.
Linus
Powered by blists - more mailing lists