From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Tobin C. Harding" Subject: Re: [PATCH] printk: hash addresses printed with %p Date: Thu, 12 Oct 2017 13:24:08 +1100 Message-ID: <20171012022408.GC30753@eros> References: <1507693696-3777-1-git-send-email-me@tobin.cc> <1507694810.3552.45.camel@perches.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kernel-hardening@lists.openwall.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , Kees Cook , Paolo Bonzini , Tycho Andersen , "Roberts, William C" , Tejun Heo , Jordan Glover , Greg KH , Petr Mladek , Ian Campbell , Sergey Senozhatsky , Catalin Marinas , Will Deacon , Steven Rostedt , Chris Fries , Dave Weinstein , Daniel Micay , To: Joe Perches Return-path: Content-Disposition: inline In-Reply-To: <1507694810.3552.45.camel@perches.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Tue, Oct 10, 2017 at 09:06:50PM -0700, Joe Perches wrote: > On Wed, 2017-10-11 at 14:48 +1100, Tobin C. Harding wrote: > > 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. > [] > > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > [] > > @@ -1591,6 +1591,35 @@ char *device_node_string(char *buf, char *end, struct device_node *dn, > > return widen_string(buf, buf - buf_start, end, spec); > > } > > > > +static long get_random_odd_long(void) > > +{ > > + long val = 0; > > + > > + while((val & 1) == 0) { > > + val = get_random_long(); > > + } > > + > > + return val; > > +} > > Perhaps > > static long get_random_odd_long(void) > { > return get_random_long() | 1L; > } > Nice. thanks, Tobin.