Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-31 Thread Jason A. Donenfeld
On Mon, Oct 30, 2017 at 9:22 PM, Steven Rostedt wrote: > How quickly do you need static_branch_disable() executed? You could > always pass the work off to a worker thread (that can schedule). > > random_ready_callback -> initiates worker thread -> enables the static branch I had already suggested

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-30 Thread Tobin C. Harding
On Mon, Oct 30, 2017 at 04:22:44PM -0400, Steven Rostedt wrote: > On Wed, 25 Oct 2017 14:49:34 +1100 > "Tobin C. Harding" wrote: > > > > First, the static_key stuff. > > > > DEFINE_STATIC_KEY_TRUE(no_ptr_secret) : Doesn't sleep, just a > > declaration. > > > > if (static_branch_unlikely(&no_pt

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-30 Thread Steven Rostedt
On Wed, 25 Oct 2017 14:49:34 +1100 "Tobin C. Harding" wrote: > > First, the static_key stuff. > > DEFINE_STATIC_KEY_TRUE(no_ptr_secret) : Doesn't sleep, just a > declaration. > > if (static_branch_unlikely(&no_ptr_secret)) {} : Doesn't sleep, just > some assembler to jump to returning true or

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-26 Thread Tobin C. Harding
On Thu, Oct 26, 2017 at 09:00:03AM +0200, Greg KH wrote: > On Thu, Oct 26, 2017 at 12:59:08AM +0200, Jason A. Donenfeld wrote: > > On Thu, Oct 26, 2017 at 12:27 AM, Tobin C. Harding wrote: > > > How good is unlikely()? > > > > It places that branch way at the bottom of the function so that it's >

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-26 Thread Greg KH
On Thu, Oct 26, 2017 at 12:59:08AM +0200, Jason A. Donenfeld wrote: > On Thu, Oct 26, 2017 at 12:27 AM, Tobin C. Harding wrote: > > How good is unlikely()? > > It places that branch way at the bottom of the function so that it's > less likely to pollute the icache. But always measure it. Lots o

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-25 Thread Tobin C. Harding
On Thu, Oct 26, 2017 at 12:59:08AM +0200, Jason A. Donenfeld wrote: > On Thu, Oct 26, 2017 at 12:27 AM, Tobin C. Harding wrote: > > How good is unlikely()? > > It places that branch way at the bottom of the function so that it's > less likely to pollute the icache. > > > It doesn't _feel_ right

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-25 Thread Jason A. Donenfeld
On Thu, Oct 26, 2017 at 12:27 AM, Tobin C. Harding wrote: > How good is unlikely()? It places that branch way at the bottom of the function so that it's less likely to pollute the icache. > It doesn't _feel_ right adding a check on every call to printk just to > check for a condition that was on

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-25 Thread Tobin C. Harding
On Wed, Oct 25, 2017 at 06:00:21AM +0200, Jason A. Donenfeld wrote: > On Wed, Oct 25, 2017 at 5:49 AM, Tobin C. Harding wrote: > > static_branch_disable(&no_ptr_secret) : Doesn't sleep, just atomic read > > and set and maybe a WARN_ONCE. > > Are you sure about that? I just looked myself, and thou

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-25 Thread Tobin C. Harding
On Wed, Oct 25, 2017 at 09:02:34PM +0200, Rasmus Villemoes wrote: > On 25 October 2017 at 01:57, Tobin C. Harding wrote: > > On Tue, Oct 24, 2017 at 09:25:20PM +0200, Rasmus Villemoes wrote: > >> > >> I haven't followed the discussion too closely, but has it been > >> considered to exempt NULL fro

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-25 Thread Rasmus Villemoes
On 25 October 2017 at 01:57, Tobin C. Harding wrote: > On Tue, Oct 24, 2017 at 09:25:20PM +0200, Rasmus Villemoes wrote: >> >> I haven't followed the discussion too closely, but has it been >> considered to exempt NULL from hashing? > [snip] > > The code in question is; > > static noinline_for_sta

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-25 Thread Tobin C. Harding
On Wed, Oct 25, 2017 at 06:00:21AM +0200, Jason A. Donenfeld wrote: > On Wed, Oct 25, 2017 at 5:49 AM, Tobin C. Harding wrote: > > static_branch_disable(&no_ptr_secret) : Doesn't sleep, just atomic read > > and set and maybe a WARN_ONCE. > > Are you sure about that? I just looked myself, and thou

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-24 Thread Jason A. Donenfeld
On Wed, Oct 25, 2017 at 5:49 AM, Tobin C. Harding wrote: > static_branch_disable(&no_ptr_secret) : Doesn't sleep, just atomic read > and set and maybe a WARN_ONCE. Are you sure about that? I just looked myself, and though there is a !HAVE_JUMP_LABEL ifdef that does what you described, there's als

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-24 Thread Tobin C. Harding
On Tue, Oct 24, 2017 at 01:25:52PM +0200, Jason A. Donenfeld wrote: > On Tue, Oct 24, 2017 at 2:31 AM, Tobin C. Harding wrote: > > On Tue, Oct 24, 2017 at 01:00:03AM +0200, Jason A. Donenfeld wrote: > >> Provided you've tested this and the static_key guard stuff actually > >> works as intended, >

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-24 Thread Tobin C. Harding
On Tue, Oct 24, 2017 at 01:25:52PM +0200, Jason A. Donenfeld wrote: > On Tue, Oct 24, 2017 at 2:31 AM, Tobin C. Harding wrote: > > On Tue, Oct 24, 2017 at 01:00:03AM +0200, Jason A. Donenfeld wrote: > >> Provided you've tested this and the static_key guard stuff actually > >> works as intended, >

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-24 Thread Jason A. Donenfeld
On Tue, Oct 24, 2017 at 2:31 AM, Tobin C. Harding wrote: > On Tue, Oct 24, 2017 at 01:00:03AM +0200, Jason A. Donenfeld wrote: >> Provided you've tested this and the static_key guard stuff actually >> works as intended, > > I tested by inserting a simple module that calls printf() with a bunch of

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-23 Thread Tobin C. Harding
On Tue, Oct 24, 2017 at 01:00:03AM +0200, Jason A. Donenfeld wrote: > Provided you've tested this and the static_key guard stuff actually > works as intended, I tested by inserting a simple module that calls printf() with a bunch of different specifiers. So it's tested but not stress tested. Some

Re: [PATCH v7] printk: hash addresses printed with %p

2017-10-23 Thread Jason A. Donenfeld
Provided you've tested this and the static_key guard stuff actually works as intended, for the crypto/rng/siphash aspects: Reviewed-by: Jason A. Donenfeld

[PATCH v7] printk: hash addresses printed with %p

2017-10-23 Thread Tobin C. Harding
Currently there are many places in the kernel where addresses are being printed using an unadorned %p. Kernel pointers should be printed using %pK allowing some control via the kptr_restrict sysctl. Exposing addresses gives attackers sensitive information about the kernel layout in memory. We can