From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:45472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRnQo-0001d0-2M for qemu-devel@nongnu.org; Wed, 01 Jun 2011 11:34:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QRnQk-0003mM-TG for qemu-devel@nongnu.org; Wed, 01 Jun 2011 11:34:02 -0400 Received: from mail-gw0-f45.google.com ([74.125.83.45]:35580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRnQk-0003m9-O6 for qemu-devel@nongnu.org; Wed, 01 Jun 2011 11:33:58 -0400 Received: by gwb19 with SMTP id 19so2693795gwb.4 for ; Wed, 01 Jun 2011 08:33:58 -0700 (PDT) Sender: Richard Henderson Message-ID: <4DE65BE3.1040004@twiddle.net> Date: Wed, 01 Jun 2011 08:33:55 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1306928551-31723-1-git-send-email-cedric.vincent@st.com> <4DE63DF1.60709@twiddle.net> <20110601134734.GA10150@gnx2503> In-Reply-To: <20110601134734.GA10150@gnx2503> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] linux-user: Define AT_RANDOM to support target dynamic linkers that do ASLR List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: cedric.vincent@st.com, "qemu-devel@nongnu.org" , Laurent ALFONSI , Riku Voipio On 06/01/2011 06:47 AM, cedric.vincent@st.com 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); 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. r~