account for the 16 bytes of AT_RANDOM data in the stack setup. fixes PR 48518.
use cprng_strong32() instead of random(). add AT_RANDOM support for linux32.
This commit is contained in:
parent
52673c8d59
commit
e5a75de98e
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_exec.h,v 1.11 2008/04/28 20:23:42 martin Exp $ */
|
||||
/* $NetBSD: linux_exec.h,v 1.12 2014/02/09 16:41:42 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -47,7 +47,8 @@
|
|||
/*
|
||||
* Alpha specific ELF defines.
|
||||
*/
|
||||
#define LINUX_ELF_AUX_ARGSIZ howmany(sizeof(Aux64Info) * LINUX_ELF_AUX_ENTRIES, sizeof(char *))
|
||||
#define LINUX_ELF_AUX_ARGSIZ \
|
||||
(howmany(sizeof(Aux64Info) * LINUX_ELF_AUX_ENTRIES, sizeof(char *)) + LINUX_RANDOM_BYTES)
|
||||
|
||||
#define linux_exec_setup_stack exec_setup_stack
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_exec.h,v 1.8 2008/04/28 20:23:42 martin Exp $ */
|
||||
/* $NetBSD: linux_exec.h,v 1.9 2014/02/09 16:41:42 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -36,7 +36,7 @@
|
|||
#define LINUX_MID_MACHINE LINUX_M_ARM
|
||||
|
||||
#define LINUX_ELF_AUX_ARGSIZ \
|
||||
(howmany(LINUX_ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr)))
|
||||
(howmany(LINUX_ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr)) + LINUX_RANDOM_BYTES)
|
||||
|
||||
#define linux_exec_setup_stack exec_setup_stack
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_exec.h,v 1.11 2012/03/21 03:20:22 chs Exp $ */
|
||||
/* $NetBSD: linux_exec.h,v 1.12 2014/02/09 16:41:42 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
#define LINUX_USRSTACK 0xC0000000
|
||||
|
||||
#define LINUX_ELF_AUX_ARGSIZ \
|
||||
(howmany(LINUX_ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr)))
|
||||
(howmany(LINUX_ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr)) + LINUX_RANDOM_BYTES)
|
||||
|
||||
#define LINUX_DEBUGLINK_SIGNATURE
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_exec.h,v 1.10 2008/04/28 20:23:42 martin Exp $ */
|
||||
/* $NetBSD: linux_exec.h,v 1.11 2014/02/09 16:41:42 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -41,7 +41,7 @@
|
|||
#define LINUX_GCC_SIGNATURE 1
|
||||
|
||||
#define LINUX_ELF_AUX_ARGSIZ \
|
||||
(howmany(LINUX_ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr)))
|
||||
(howmany(LINUX_ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr)) + LINUX_RANDOM_BYTES)
|
||||
|
||||
#define linux_exec_setup_stack exec_setup_stack
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_exec.h,v 1.14 2009/08/13 03:56:32 matt Exp $ */
|
||||
/* $NetBSD: linux_exec.h,v 1.15 2014/02/09 16:41:42 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -59,7 +59,7 @@
|
|||
#define LINUX_GCC_SIGNATURE 1
|
||||
|
||||
#define LINUX_ELF_AUX_ARGSIZ \
|
||||
((howmany(LINUX_ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr))))
|
||||
(howmany(LINUX_ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr)) + LINUX_RANDOM_BYTES)
|
||||
|
||||
#define linux_exec_setup_stack exec_setup_stack
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_exec.h,v 1.22 2014/01/25 10:14:29 skrll Exp $ */
|
||||
/* $NetBSD: linux_exec.h,v 1.23 2014/02/09 16:41:42 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -81,8 +81,7 @@
|
|||
* by PowerPC GNU ld.so).
|
||||
*/
|
||||
#define LINUX_ELF_AUX_ARGSIZ \
|
||||
((howmany(LINUX_ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr))) \
|
||||
+ 16)
|
||||
(howmany(LINUX_ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr)) + LINUX_RANDOM_BYTES + 16)
|
||||
|
||||
/* we have special powerpc ELF copyargs */
|
||||
#define LINUX_MACHDEP_ELF_COPYARGS
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_exec.h,v 1.49 2013/11/18 01:32:22 chs Exp $ */
|
||||
/* $NetBSD: linux_exec.h,v 1.50 2014/02/09 16:41:42 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -100,6 +100,8 @@
|
|||
#define LINUX_AT_SYSINFO 32 /* pointer to __kernel_vsyscall */
|
||||
#define LINUX_AT_SYSINFO_EHDR 33 /* pointer to ELF header */
|
||||
|
||||
#define LINUX_RANDOM_BYTES 16 /* 16 bytes for AT_RANDOM */
|
||||
|
||||
/*
|
||||
* Emulation specific sysctls.
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_exec_elf32.c,v 1.87 2013/11/18 01:32:22 chs Exp $ */
|
||||
/* $NetBSD: linux_exec_elf32.c,v 1.88 2014/02/09 16:41:42 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -35,7 +35,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.87 2013/11/18 01:32:22 chs Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.88 2014/02/09 16:41:42 chs Exp $");
|
||||
|
||||
#ifndef ELFSIZE
|
||||
/* XXX should die */
|
||||
|
@ -54,6 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.87 2013/11/18 01:32:22 chs Ex
|
|||
#include <sys/exec_elf.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/kauth.h>
|
||||
#include <sys/cprng.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
@ -483,10 +484,10 @@ ELFNAME2(linux,copyargs)(struct lwp *l, struct exec_package *pack,
|
|||
a->a_v = 0;
|
||||
a++;
|
||||
|
||||
randbytes[0] = random();
|
||||
randbytes[1] = random();
|
||||
randbytes[2] = random();
|
||||
randbytes[3] = random();
|
||||
randbytes[0] = cprng_strong32();
|
||||
randbytes[1] = cprng_strong32();
|
||||
randbytes[2] = cprng_strong32();
|
||||
randbytes[3] = cprng_strong32();
|
||||
|
||||
len = sizeof(randbytes);
|
||||
if ((error = copyout(randbytes, *stackp, len)) != 0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux32_exec.h,v 1.4 2010/07/07 01:30:35 chs Exp $ */
|
||||
/* $NetBSD: linux32_exec.h,v 1.5 2014/02/09 16:41:42 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
|
||||
|
@ -43,6 +43,8 @@
|
|||
|
||||
#define LINUX32_ELF_AUX_ENTRIES 14
|
||||
|
||||
#define LINUX32_RANDOM_BYTES 16 /* 16 bytes for AT_RANDOM */
|
||||
|
||||
#if 0
|
||||
|
||||
/* Hardware platform identifier string */
|
||||
|
@ -75,7 +77,7 @@ struct linux32_extra_stack_data {
|
|||
#endif
|
||||
|
||||
#define LINUX32_ELF_AUX_ARGSIZ \
|
||||
(howmany(LINUX32_ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr)))
|
||||
(howmany(LINUX32_ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof(Elf32_Addr)) + LINUX32_RANDOM_BYTES)
|
||||
|
||||
#ifdef _KERNEL
|
||||
int linux32_exec_setup_stack(struct lwp *, struct exec_package *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux32_exec_elf32.c,v 1.13 2012/02/03 20:11:54 matt Exp $ */
|
||||
/* $NetBSD: linux32_exec_elf32.c,v 1.14 2014/02/09 16:41:42 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998, 2000, 2001,2006 The NetBSD Foundation, Inc.
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux32_exec_elf32.c,v 1.13 2012/02/03 20:11:54 matt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux32_exec_elf32.c,v 1.14 2014/02/09 16:41:42 chs Exp $");
|
||||
|
||||
#define ELFSIZE 32
|
||||
|
||||
|
@ -46,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux32_exec_elf32.c,v 1.13 2012/02/03 20:11:54 matt
|
|||
#include <sys/resourcevar.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/cprng.h>
|
||||
|
||||
#include <compat/linux/common/linux_exec.h>
|
||||
#include <compat/netbsd32/netbsd32.h>
|
||||
|
@ -107,6 +108,7 @@ linux32_elf32_copyargs(struct lwp *l, struct exec_package *pack,
|
|||
struct ps_strings *arginfo, char **stackp, void *argp)
|
||||
{
|
||||
Aux32Info ai[LINUX32_ELF_AUX_ENTRIES], *a;
|
||||
uint32_t randbytes[4];
|
||||
struct elf_args *ap;
|
||||
struct vattr *vap;
|
||||
size_t len;
|
||||
|
@ -184,6 +186,10 @@ linux32_elf32_copyargs(struct lwp *l, struct exec_package *pack,
|
|||
a->a_v = 0;
|
||||
a++;
|
||||
|
||||
a->a_type = LINUX_AT_RANDOM;
|
||||
a->a_v = NETBSD32PTR32I(*stackp);
|
||||
a++;
|
||||
|
||||
#if 0
|
||||
a->a_type = LINUX_AT_SYSINFO;
|
||||
a->a_v = NETBSD32PTR32I(&esdp->kernel_vsyscall[0]);
|
||||
|
@ -206,6 +212,16 @@ linux32_elf32_copyargs(struct lwp *l, struct exec_package *pack,
|
|||
a->a_v = 0;
|
||||
a++;
|
||||
|
||||
randbytes[0] = cprng_strong32();
|
||||
randbytes[1] = cprng_strong32();
|
||||
randbytes[2] = cprng_strong32();
|
||||
randbytes[3] = cprng_strong32();
|
||||
|
||||
len = sizeof(randbytes);
|
||||
if ((error = copyout(randbytes, *stackp, len)) != 0)
|
||||
return error;
|
||||
*stackp += len;
|
||||
|
||||
#if 0
|
||||
memcpy(esd.kernel_vsyscall, linux32_kernel_vsyscall,
|
||||
sizeof(linux32_kernel_vsyscall));
|
||||
|
|
Loading…
Reference in New Issue