Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 10 Oct 2017 21:06:50 -0700
From: Joe Perches <joe@...ches.com>
To: "Tobin C. Harding" <me@...in.cc>, kernel-hardening@...ts.openwall.com, 
	kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: 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>, Ian Campbell <ijc@...lion.org.uk>, Sergey
 Senozhatsky <sergey.senozhatsky@...il.com>,  Catalin Marinas
 <catalin.marinas@....com>, Will Deacon <will.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>
Subject: Re: [PATCH] printk: hash addresses printed with %p

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;
}

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.