From: "Tobin C. Harding" <me@tobin.cc>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: kernel-hardening@lists.openwall.com,
Linus Torvalds <torvalds@linux-foundation.org>,
Kees Cook <keescook@chromium.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Tycho Andersen <tycho@docker.com>,
"Roberts, William C" <william.c.roberts@intel.com>,
Tejun Heo <tj@kernel.org>,
Jordan Glover <Golden_Miller83@protonmail.ch>,
Greg KH <gregkh@linuxfoundation.org>,
Petr Mladek <pmladek@suse.com>, Joe Perches <joe@perches.com>,
Ian Campbell <ijc@hellion.org.uk>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Chris Fries <cfries@google.com>,
Dave Weinstein <olorin@google.com>,
Daniel Micay <danielmicay@gmail.com>,
Djalal Harouni <tixxdz@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] printk: hash addresses printed with %p
Date: Wed, 18 Oct 2017 17:04:06 +1100 [thread overview]
Message-ID: <20171018060406.GA28753@eros> (raw)
In-Reply-To: <20171018054431.GA597@jagdpanzerIV>
On Wed, Oct 18, 2017 at 02:44:31PM +0900, Sergey Senozhatsky wrote:
> On (10/18/17 15:21), Tobin C. Harding wrote:
> [..]
> > diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> > index 86c3385b9eb3..4609738cd2cd 100644
> > --- a/lib/vsprintf.c
> > +++ b/lib/vsprintf.c
> > @@ -33,6 +33,8 @@
> > #include <linux/uuid.h>
> > #include <linux/of.h>
> > #include <net/addrconf.h>
> > +#include <linux/siphash.h>
> > +#include <linux/spinlock.h>
> > #ifdef CONFIG_BLOCK
> > #include <linux/blkdev.h>
> > #endif
> > @@ -1591,6 +1593,70 @@ char *device_node_string(char *buf, char *end, struct device_node *dn,
> > return widen_string(buf, buf - buf_start, end, spec);
> > }
> >
> > +/* protects ptr_secret and have_key */
> > +DEFINE_SPINLOCK(key_lock);
> > +static siphash_key_t ptr_secret __read_mostly;
> > +static atomic_t have_key = ATOMIC_INIT(0);
> > +
> > +static int initialize_ptr_secret(void)
> > +{
> > + spin_lock(&key_lock);
> > + if (atomic_read(&have_key) == 1)
> > + goto unlock;
> > +
> > + get_random_bytes(&ptr_secret, sizeof(ptr_secret));
> > + atomic_set(&have_key, 1);
> > +
> > +unlock:
> > + spin_unlock(&key_lock);
> > + return 0;
> > +}
>
> is this spinlock legal? what happens if we are getting interrupted by NMI?
I think we can do without the spinlock. I think I was already told that when
I tried to put it [some where else] in v1.
It's fun failing in public ;)
> printk()
> vprintk_emit()
> vscnprintf()
> pointer()
> ptr_to_id()
> initialize_ptr_secret()
> spin_lock(&key_lock)
>
> ----> NMI
>
> printk()
> printk_safe_log_store()
> vscnprintf()
> pointer()
> ptr_to_id()
> initialize_ptr_secret()
> spin_lock(&key_lock) <<<<
>
>
> or am I completely misreading the patch? sorry if so.
>
> -ss
thanks,
Tobin.
next prev parent reply other threads:[~2017-10-18 6:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-18 4:21 [PATCH v4] printk: hash addresses printed with %p Tobin C. Harding
2017-10-18 5:44 ` Sergey Senozhatsky
2017-10-18 6:04 ` Tobin C. Harding [this message]
2017-10-19 0:00 ` Sergey Senozhatsky
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=20171018060406.GA28753@eros \
--to=me@tobin.cc \
--cc=Golden_Miller83@protonmail.ch \
--cc=catalin.marinas@arm.com \
--cc=cfries@google.com \
--cc=danielmicay@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=ijc@hellion.org.uk \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=olorin@google.com \
--cc=pbonzini@redhat.com \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=tixxdz@gmail.com \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tycho@docker.com \
--cc=will.deacon@arm.com \
--cc=william.c.roberts@intel.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox