[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] linux-user: Define AT_RANDOM to support target
From: |
cedric.vincent |
Subject: |
Re: [Qemu-devel] [PATCH] linux-user: Define AT_RANDOM to support target dynamic linkers that do ASLR |
Date: |
Fri, 3 Jun 2011 08:46:19 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, Jun 01, 2011 at 05:33:55PM +0200, Richard Henderson wrote:
> On 06/01/2011 06:47 AM, address@hidden wrote:
> > On Wed, Jun 01, 2011 at 03:26:09PM +0200, Richard Henderson wrote:
> >>
> >> 16 bytes, not 16 bits.
> >
> > You're right it's not 16 bits, it's "sizeof(uintptr_t)" actually:
>
> No, it's not.
>
> unsigned char k_rand_bytes[16];
> elf_addr_t __user *u_rand_bytes;
> ...
> /*
> * Generate 16 random bytes for userspace PRNG seeding.
> */
> get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
> u_rand_bytes = (elf_addr_t __user *)
> STACK_ALLOC(p, sizeof(k_rand_bytes));
> if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
> return -EFAULT;
> ...
> NEW_AUX_ENT(AT_RANDOM, (elf_addr_t)(unsigned long)u_rand_bytes);
It's clearer to me now, thanks.
> Frankly, it's trivial to do this right in create_elf_tables.
> Grab 16 bytes at SP right at the beginning of the function,
> fill it with whatever random values seem good.
>
> I suggest at minimum a command-line argument to force a
> particular AT_RANDOM value, for repeatability.
OK, I will submit you such a patch soon.
Thanks,
Cédric.