|
Message-ID: <20171030224102.GY12341@eros> Date: Tue, 31 Oct 2017 09:41:02 +1100 From: "Tobin C. Harding" <me@...in.cc> To: Steven Rostedt <rostedt@...dmis.org> Cc: kernel-hardening@...ts.openwall.com, "Jason A. Donenfeld" <Jason@...c4.com>, Theodore Ts'o <tytso@....edu>, Linus Torvalds <torvalds@...ux-foundation.org>, Kees Cook <keescook@...omium.org>, Paolo Bonzini <pbonzini@...hat.com>, Tycho Andersen <tycho@...ker.com>, "Roberts, William C" <william.c.roberts@...el.com>, Tejun Heo <tj@...nel.org>, Jordan Glover <Golden_Miller83@...tonmail.ch>, Greg KH <gregkh@...uxfoundation.org>, Petr Mladek <pmladek@...e.com>, Joe Perches <joe@...ches.com>, Ian Campbell <ijc@...lion.org.uk>, Sergey Senozhatsky <sergey.senozhatsky@...il.com>, Catalin Marinas <catalin.marinas@....com>, Will Deacon <wilal.deacon@....com>, Chris Fries <cfries@...gle.com>, Dave Weinstein <olorin@...gle.com>, Daniel Micay <danielmicay@...il.com>, Djalal Harouni <tixxdz@...il.com>, linux-kernel@...r.kernel.org Subject: Re: [PATCH V8 2/2] printk: hash addresses printed with %p On Mon, Oct 30, 2017 at 05:33:22PM -0400, Steven Rostedt wrote: > On Thu, 26 Oct 2017 13:58:38 +1100 > "Tobin C. Harding" <me@...in.cc> wrote: > > > > +static bool have_filled_random_ptr_key; > > > +static siphash_key_t ptr_key __read_mostly; > > > + > > > +static void fill_random_ptr_key(struct random_ready_callback *unused) > > > +{ > > > + get_random_bytes(&ptr_key, sizeof(ptr_key)); > > > + WRITE_ONCE(have_filled_random_ptr_key, true); > > > > This usage of WRITE_ONCE was suggested by Jason A. Donenfeld. I read > > include/linux/compiler.h but was not able to grok it. Is this enough to > > stop the compiler re-ordering these two statements? > > > > Or do I need to read Documentation/memory-barriers.txt [again]? > > No, the WRITE_ONCE does not stop the compiler from reordering those > statements. If you need that, then you need to do: > > get_random_bytes(&ptr_key, sizeof(ptr_key)); > barrier(); > WRITE_ONCE(have_filled_random_ptr_key, true); > > and that only works against interrupts. If you need synchronization > across CPUs, then you need smp_mb(). Cool. So I think we need get_random_bytes(&ptr_key, sizeof(ptr_key)); smp_mb(); WRITE_ONCE(have_filled_random_ptr_key, true); V10 to include this unless I have it wrong. thanks, Tobin.
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.