|
Message-ID: <20171022233216.GM29874@eros> Date: Mon, 23 Oct 2017 10:32:16 +1100 From: "Tobin C. Harding" <me@...in.cc> To: "Jason A. Donenfeld" <Jason@...c4.com> Cc: Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>, kernel-hardening@...ts.openwall.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>, Steven Rostedt <rostedt@...dmis.org>, Chris Fries <cfries@...gle.com>, Dave Weinstein <olorin@...gle.com>, Daniel Micay <danielmicay@...il.com>, Djalal Harouni <tixxdz@...il.com>, LKML <linux-kernel@...r.kernel.org> Subject: Re: [PATCH v5] printk: hash addresses printed with %p On Thu, Oct 19, 2017 at 07:49:06AM +0200, Jason A. Donenfeld wrote: > A small detail carried over from the other thread: > > > > > but a bigger problem might the following thing: > > > > vscnprintf() > > pointer() > > ptr_to_id() > > initialize_ptr_secret() > > get_random_bytes() > > _get_random_bytes() > > extract_crng() > > _extract_crng() > > spin_lock_irqsave(&crng->lock, flags); <<<<< > > > > > > this, once again, can deadlock. can it? just like before: > > So, actually, then, we need to do this as an initcall. Fortunately, > that simplifies things greatly. Here's a rough sketch of what that > looks like, which you'll probably need to debug and refine: > > > > static siphash_key_t ptr_secret __ro_after_init; > static DEFINE_STATIC_KEY_TRUE(no_ptr_secret); > > static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec) > { > if (static_branch_unlikely(&no_ptr_secret)) > return "(pointer value)"; > > hashval = .... > > } > > static void fill_random_ptr_key(struct random_ready_callback *rdy) > { > get_random_bytes(&ptr_secret, sizeof(ptr_secret)); > static_branch_disable(&no_ptr_secret); > } > > static struct random_ready_callback random_ready = { > .func = fill_random_ptr_key > }; > > static int __init initialize_ptr_random(void) > { > int ret = add_random_ready_callback(&random_ready); > > if (!ret) > return 0; > else if (ret == -EALREADY) { > fill_random_ptr_key(&random_ready); > return 0; > } > > return ret; > } > early_initcall(initialize_ptr_random); Thanks for this Jason. This is _conceptually_ what I wanted since before v1, I obviously did not ask the right questions. Not to worry, we got there in the end. The process works, thanks to every bodies patience :) Implemented for v6 as suggested (including __read_mostly), you even got it fast for the usual case. Thanks, I learned a whole bunch from this email. 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.