Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat account for the 16 bytes of AT_RANDOM data in the...
details: https://anonhg.NetBSD.org/src/rev/0e5d57024e01
branches: trunk
changeset: 326647:0e5d57024e01
user: chs <chs%NetBSD.org@localhost>
date: Sun Feb 09 16:41:42 2014 +0000
description:
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.
diffstat:
sys/compat/linux/arch/alpha/linux_exec.h | 5 +++--
sys/compat/linux/arch/arm/linux_exec.h | 4 ++--
sys/compat/linux/arch/i386/linux_exec.h | 4 ++--
sys/compat/linux/arch/m68k/linux_exec.h | 4 ++--
sys/compat/linux/arch/mips/linux_exec.h | 4 ++--
sys/compat/linux/arch/powerpc/linux_exec.h | 5 ++---
sys/compat/linux/common/linux_exec.h | 4 +++-
sys/compat/linux/common/linux_exec_elf32.c | 13 +++++++------
sys/compat/linux32/arch/amd64/linux32_exec.h | 6 ++++--
sys/compat/linux32/common/linux32_exec_elf32.c | 20 ++++++++++++++++++--
10 files changed, 45 insertions(+), 24 deletions(-)
diffs (258 lines):
diff -r 70d93365f0e7 -r 0e5d57024e01 sys/compat/linux/arch/alpha/linux_exec.h
--- a/sys/compat/linux/arch/alpha/linux_exec.h Sun Feb 09 14:51:13 2014 +0000
+++ b/sys/compat/linux/arch/alpha/linux_exec.h Sun Feb 09 16:41:42 2014 +0000
@@ -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
diff -r 70d93365f0e7 -r 0e5d57024e01 sys/compat/linux/arch/arm/linux_exec.h
--- a/sys/compat/linux/arch/arm/linux_exec.h Sun Feb 09 14:51:13 2014 +0000
+++ b/sys/compat/linux/arch/arm/linux_exec.h Sun Feb 09 16:41:42 2014 +0000
@@ -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
diff -r 70d93365f0e7 -r 0e5d57024e01 sys/compat/linux/arch/i386/linux_exec.h
--- a/sys/compat/linux/arch/i386/linux_exec.h Sun Feb 09 14:51:13 2014 +0000
+++ b/sys/compat/linux/arch/i386/linux_exec.h Sun Feb 09 16:41:42 2014 +0000
@@ -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
diff -r 70d93365f0e7 -r 0e5d57024e01 sys/compat/linux/arch/m68k/linux_exec.h
--- a/sys/compat/linux/arch/m68k/linux_exec.h Sun Feb 09 14:51:13 2014 +0000
+++ b/sys/compat/linux/arch/m68k/linux_exec.h Sun Feb 09 16:41:42 2014 +0000
@@ -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
diff -r 70d93365f0e7 -r 0e5d57024e01 sys/compat/linux/arch/mips/linux_exec.h
--- a/sys/compat/linux/arch/mips/linux_exec.h Sun Feb 09 14:51:13 2014 +0000
+++ b/sys/compat/linux/arch/mips/linux_exec.h Sun Feb 09 16:41:42 2014 +0000
@@ -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
diff -r 70d93365f0e7 -r 0e5d57024e01 sys/compat/linux/arch/powerpc/linux_exec.h
--- a/sys/compat/linux/arch/powerpc/linux_exec.h Sun Feb 09 14:51:13 2014 +0000
+++ b/sys/compat/linux/arch/powerpc/linux_exec.h Sun Feb 09 16:41:42 2014 +0000
@@ -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
diff -r 70d93365f0e7 -r 0e5d57024e01 sys/compat/linux/common/linux_exec.h
--- a/sys/compat/linux/common/linux_exec.h Sun Feb 09 14:51:13 2014 +0000
+++ b/sys/compat/linux/common/linux_exec.h Sun Feb 09 16:41:42 2014 +0000
@@ -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.
*/
diff -r 70d93365f0e7 -r 0e5d57024e01 sys/compat/linux/common/linux_exec_elf32.c
--- a/sys/compat/linux/common/linux_exec_elf32.c Sun Feb 09 14:51:13 2014 +0000
+++ b/sys/compat/linux/common/linux_exec_elf32.c Sun Feb 09 16:41:42 2014 +0000
@@ -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 @@
#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 @@
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)
diff -r 70d93365f0e7 -r 0e5d57024e01 sys/compat/linux32/arch/amd64/linux32_exec.h
--- a/sys/compat/linux32/arch/amd64/linux32_exec.h Sun Feb 09 14:51:13 2014 +0000
+++ b/sys/compat/linux32/arch/amd64/linux32_exec.h Sun Feb 09 16:41:42 2014 +0000
@@ -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 @@
#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 *);
diff -r 70d93365f0e7 -r 0e5d57024e01 sys/compat/linux32/common/linux32_exec_elf32.c
--- a/sys/compat/linux32/common/linux32_exec_elf32.c Sun Feb 09 14:51:13 2014 +0000
+++ b/sys/compat/linux32/common/linux32_exec_elf32.c Sun Feb 09 16:41:42 2014 +0000
@@ -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 @@
#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 @@
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 @@
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 @@
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));
Home |
Main Index |
Thread Index |
Old Index