Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/linux implement AT_RANDOM.
details: https://anonhg.NetBSD.org/src/rev/115f2304d8bb
branches: trunk
changeset: 791429:115f2304d8bb
user: chs <chs%NetBSD.org@localhost>
date: Mon Nov 18 01:32:22 2013 +0000
description:
implement AT_RANDOM.
diffstat:
sys/compat/linux/arch/amd64/linux_exec.h | 5 +++--
sys/compat/linux/arch/amd64/linux_exec_machdep.c | 11 +++++++++--
sys/compat/linux/common/linux_exec.h | 5 +++--
sys/compat/linux/common/linux_exec_elf32.c | 19 +++++++++++++++++--
4 files changed, 32 insertions(+), 8 deletions(-)
diffs (135 lines):
diff -r edfdf13dc53a -r 115f2304d8bb sys/compat/linux/arch/amd64/linux_exec.h
--- a/sys/compat/linux/arch/amd64/linux_exec.h Mon Nov 18 01:31:42 2013 +0000
+++ b/sys/compat/linux/arch/amd64/linux_exec.h Mon Nov 18 01:32:22 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_exec.h,v 1.4 2006/08/07 14:19:57 manu Exp $ */
+/* $NetBSD: linux_exec.h,v 1.5 2013/11/18 01:32:22 chs Exp $ */
/*-
* Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@@ -47,7 +47,7 @@
#define LINUX_USRSTACK32 0xc0000000
/* Counted from linux_exec_machdep.c */
-#define LINUX_ELF_AUX_ENTRIES 16
+#define LINUX_ELF_AUX_ENTRIES 17
/* Hardware platform identifier string */
#define LINUX_PLATFORM "x86_64"
@@ -55,6 +55,7 @@
/* The extra data (ELF auxiliary table and platform name) on stack */
struct linux_extra_stack_data64 {
Aux64Info ai[LINUX_ELF_AUX_ENTRIES];
+ uint32_t randbytes[4];
char pad[1]; /*sizeof(long) - (sizeof(LINUX_PLATFORM) % sizeof(long))*/
char hw_platform[sizeof(LINUX_PLATFORM)];
};
diff -r edfdf13dc53a -r 115f2304d8bb sys/compat/linux/arch/amd64/linux_exec_machdep.c
--- a/sys/compat/linux/arch/amd64/linux_exec_machdep.c Mon Nov 18 01:31:42 2013 +0000
+++ b/sys/compat/linux/arch/amd64/linux_exec_machdep.c Mon Nov 18 01:32:22 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_exec_machdep.c,v 1.19 2012/02/03 20:11:53 matt Exp $ */
+/* $NetBSD: linux_exec_machdep.c,v 1.20 2013/11/18 01:32:22 chs Exp $ */
/*-
* Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_exec_machdep.c,v 1.19 2012/02/03 20:11:53 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_exec_machdep.c,v 1.20 2013/11/18 01:32:22 chs Exp $");
#define ELFSIZE 64
@@ -223,6 +223,13 @@
esd.ai[i].a_type = LINUX_AT_PLATFORM;
esd.ai[i++].a_v = (Elf_Addr)&esdp->hw_platform[0];
+ esd.ai[i].a_type = LINUX_AT_RANDOM;
+ esd.ai[i++].a_v = (Elf_Addr)&esdp->randbytes[0];
+ esd.randbytes[0] = random();
+ esd.randbytes[1] = random();
+ esd.randbytes[2] = random();
+ esd.randbytes[3] = random();
+
esd.ai[i].a_type = AT_NULL;
esd.ai[i++].a_v = 0;
diff -r edfdf13dc53a -r 115f2304d8bb sys/compat/linux/common/linux_exec.h
--- a/sys/compat/linux/common/linux_exec.h Mon Nov 18 01:31:42 2013 +0000
+++ b/sys/compat/linux/common/linux_exec.h Mon Nov 18 01:32:22 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_exec.h,v 1.48 2010/07/07 01:30:35 chs Exp $ */
+/* $NetBSD: linux_exec.h,v 1.49 2013/11/18 01:32:22 chs Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -82,7 +82,7 @@
#define LINUX_N_BSSADDR(x,m) (LINUX_N_DATADDR(x,m) + (x).a_data)
#ifndef LINUX_MACHDEP_ELF_COPYARGS
-#define LINUX_ELF_AUX_ENTRIES 13 /* we push 13 parameters */
+#define LINUX_ELF_AUX_ENTRIES 14
#endif
/*
@@ -96,6 +96,7 @@
#define LINUX_AT_HWCAP 16 /* arch dependent CPU capabilities */
#define LINUX_AT_CLKTCK 17 /* frequency times() increments */
#define LINUX_AT_SECURE 23 /* secure mode boolean */
+#define LINUX_AT_RANDOM 25 /* address of 16 random bytes */
#define LINUX_AT_SYSINFO 32 /* pointer to __kernel_vsyscall */
#define LINUX_AT_SYSINFO_EHDR 33 /* pointer to ELF header */
diff -r edfdf13dc53a -r 115f2304d8bb sys/compat/linux/common/linux_exec_elf32.c
--- a/sys/compat/linux/common/linux_exec_elf32.c Mon Nov 18 01:31:42 2013 +0000
+++ b/sys/compat/linux/common/linux_exec_elf32.c Mon Nov 18 01:32:22 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_exec_elf32.c,v 1.86 2012/02/12 16:34:10 matt Exp $ */
+/* $NetBSD: linux_exec_elf32.c,v 1.87 2013/11/18 01:32:22 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.86 2012/02/12 16:34:10 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.87 2013/11/18 01:32:22 chs Exp $");
#ifndef ELFSIZE
/* XXX should die */
@@ -402,6 +402,7 @@
struct elf_args *ap;
int error;
struct vattr *vap;
+ uint32_t randbytes[4];
if ((error = copyargs(l, pack, arginfo, stackp, argp)) != 0)
return error;
@@ -474,10 +475,24 @@
a->a_v = kauth_cred_getegid(l->l_cred);
a++;
+ a->a_type = LINUX_AT_RANDOM;
+ a->a_v = (Elf_Addr)*stackp;
+ a++;
+
a->a_type = AT_NULL;
a->a_v = 0;
a++;
+ randbytes[0] = random();
+ randbytes[1] = random();
+ randbytes[2] = random();
+ randbytes[3] = random();
+
+ len = sizeof(randbytes);
+ if ((error = copyout(randbytes, *stackp, len)) != 0)
+ return error;
+ *stackp += len;
+
len = (a - ai) * sizeof(AuxInfo);
if ((error = copyout(ai, *stackp, len)) != 0)
return error;
Home |
Main Index |
Thread Index |
Old Index