lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 26 Apr 2013 08:30:59 -0700
From:	Kees Cook <keescook@...omium.org>
To:	Mathias Krause <minipli@...glemail.com>
Cc:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"kernel-hardening@...ts.openwall.com" 
	<kernel-hardening@...ts.openwall.com>,
	"H. Peter Anvin" <hpa@...or.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"x86@...nel.org" <x86@...nel.org>,
	Jarkko Sakkinen <jarkko.sakkinen@...el.com>,
	Matthew Garrett <mjg@...hat.com>,
	Matt Fleming <matt.fleming@...el.com>,
	Eric Northup <digitaleric@...gle.com>,
	Dan Rosenberg <drosenberg@...curity.com>,
	Julien Tinnes <jln@...gle.com>, Will Drewry <wad@...omium.org>
Subject: Re: [kernel-hardening] [PATCH 4/6] x86: kaslr: select random base offset

On Thu, Apr 25, 2013 at 11:13 PM, Mathias Krause <minipli@...glemail.com> wrote:
> On Thu, Apr 25, 2013 at 11:54 PM, Kees Cook <keescook@...omium.org> wrote:
>> Select a random location when CONFIG_RANDOMIZE_BASE is used, bounded
>> by CONFIG_RANDOMIZE_BASE_MAX_OFFSET. Sources of randomness currently
>> include RDRAND and RDTSC.
>>
>> Signed-off-by: Kees Cook <keescook@...omium.org>
>> ---
>>  arch/x86/Kconfig                |   29 +++++++++++++--
>>  arch/x86/boot/compressed/aslr.c |   75 +++++++++++++++++++++++++++++++++++++--
>>  2 files changed, 100 insertions(+), 4 deletions(-)
>>
>> [snip]
>>
>> diff --git a/arch/x86/boot/compressed/aslr.c b/arch/x86/boot/compressed/aslr.c
>> index d5331ee..11a91c6 100644
>> --- a/arch/x86/boot/compressed/aslr.c
>> +++ b/arch/x86/boot/compressed/aslr.c
>> @@ -2,18 +2,89 @@
>>
>>  #ifdef CONFIG_RANDOMIZE_BASE
>>
>> +#include <asm/archrandom.h>
>> +static inline int rdrand(unsigned long *v)
>> +{
>> +       int ok;
>> +       asm volatile("1: " RDRAND_LONG "\n\t"
>> +                    "jc 2f\n\t"
>> +                    "decl %0\n\t"
>> +                    "jnz 1b\n\t"
>> +                    "2:"
>> +                    : "=r" (ok), "=a" (*v)
>> +                    : "0" (RDRAND_RETRY_LOOPS));
>> +       return ok;
>> +}
>> +
>> +static inline uint32_t rdtsc(void)
>> +{
>> +       uint32_t timer;
>> +
>> +       asm volatile("rdtsc\n" : "=a" (timer));
>
> '\n' in the assembly statement is not needed. Also, RDTSC trashes
> edx/rdx as well so it should be mentioned in the clobber list, at
> least.
> Maybe using rdtscl() from <asm/msr.h> instead is an option?

Ah yeah, rdtscl is perfect. I'll use that instead.

Thanks!

-Kees

-- 
Kees Cook
Chrome OS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ