Increase LINUX32_ELF_AUX_ENTRIES to avoid overrun in linux32/. Also, add comments and KASSERTs to make sure people don't forget to increase XX_AUX_ENTRIES's when adding vectors. Reported by martin@ (CV), with suggestions from chs@. ok martin@ chs@diff -r1.20 -r1.21 src/sys/compat/linux/arch/amd64/linux_exec_machdep.c
(maxv)
--- src/sys/compat/linux/arch/amd64/linux_exec_machdep.c 2013/11/18 01:32:22 1.20
+++ src/sys/compat/linux/arch/amd64/linux_exec_machdep.c 2014/02/21 07:53:53 1.21
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: linux_exec_machdep.c,v 1.20 2013/11/18 01:32:22 chs Exp $ */ | 1 | /* $NetBSD: linux_exec_machdep.c,v 1.21 2014/02/21 07:53:53 maxv Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved | 4 | * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * 3. All advertising materials mentioning features or use of this software | 14 | * 3. All advertising materials mentioning features or use of this software | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
23 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 23 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS | 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS | |
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
31 | * POSSIBILITY OF SUCH DAMAGE. | 31 | * POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: linux_exec_machdep.c,v 1.20 2013/11/18 01:32:22 chs Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: linux_exec_machdep.c,v 1.21 2014/02/21 07:53:53 maxv Exp $"); | |
36 | 36 | |||
37 | #define ELFSIZE 64 | 37 | #define ELFSIZE 64 | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
41 | #include <sys/kernel.h> | 41 | #include <sys/kernel.h> | |
42 | #include <sys/resource.h> | 42 | #include <sys/resource.h> | |
43 | #include <sys/proc.h> | 43 | #include <sys/proc.h> | |
44 | #include <sys/conf.h> | 44 | #include <sys/conf.h> | |
45 | #include <sys/kmem.h> | 45 | #include <sys/kmem.h> | |
46 | #include <sys/exec_elf.h> | 46 | #include <sys/exec_elf.h> | |
47 | #include <sys/vnode.h> | 47 | #include <sys/vnode.h> | |
48 | #include <sys/lwp.h> | 48 | #include <sys/lwp.h> | |
@@ -223,33 +223,28 @@ ELFNAME2(linux,copyargs)(struct lwp *l, | @@ -223,33 +223,28 @@ ELFNAME2(linux,copyargs)(struct lwp *l, | |||
223 | esd.ai[i].a_type = LINUX_AT_PLATFORM; | 223 | esd.ai[i].a_type = LINUX_AT_PLATFORM; | |
224 | esd.ai[i++].a_v = (Elf_Addr)&esdp->hw_platform[0]; | 224 | esd.ai[i++].a_v = (Elf_Addr)&esdp->hw_platform[0]; | |
225 | 225 | |||
226 | esd.ai[i].a_type = LINUX_AT_RANDOM; | 226 | esd.ai[i].a_type = LINUX_AT_RANDOM; | |
227 | esd.ai[i++].a_v = (Elf_Addr)&esdp->randbytes[0]; | 227 | esd.ai[i++].a_v = (Elf_Addr)&esdp->randbytes[0]; | |
228 | esd.randbytes[0] = random(); | 228 | esd.randbytes[0] = random(); | |
229 | esd.randbytes[1] = random(); | 229 | esd.randbytes[1] = random(); | |
230 | esd.randbytes[2] = random(); | 230 | esd.randbytes[2] = random(); | |
231 | esd.randbytes[3] = random(); | 231 | esd.randbytes[3] = random(); | |
232 | 232 | |||
233 | esd.ai[i].a_type = AT_NULL; | 233 | esd.ai[i].a_type = AT_NULL; | |
234 | esd.ai[i++].a_v = 0; | 234 | esd.ai[i++].a_v = 0; | |
235 | 235 | |||
236 | #ifdef DEBUG_LINUX | 236 | KASSERT(i == LINUX_ELF_AUX_ENTRIES); | |
237 | if (i != LINUX_ELF_AUX_ENTRIES) { | 237 | ||
238 | printf("linux_elf64_copyargs: %d Aux entries\n", i); | |||
239 | return EINVAL; | |||
240 | } | |||
241 | #endif | |||
242 | ||||
243 | strcpy(esd.hw_platform, LINUX_PLATFORM); | 238 | strcpy(esd.hw_platform, LINUX_PLATFORM); | |
244 | 239 | |||
245 | exec_free_emul_arg(pack); | 240 | exec_free_emul_arg(pack); | |
246 | 241 | |||
247 | /* | 242 | /* | |
248 | * Copy out the ELF auxiliary table and hw platform name | 243 | * Copy out the ELF auxiliary table and hw platform name | |
249 | */ | 244 | */ | |
250 | if ((error = copyout(&esd, esdp, sizeof(esd))) != 0) | 245 | if ((error = copyout(&esd, esdp, sizeof(esd))) != 0) | |
251 | return error; | 246 | return error; | |
252 | *stackp += sizeof(esd); | 247 | *stackp += sizeof(esd); | |
253 | 248 | |||
254 | return 0; | 249 | return 0; | |
255 | } | 250 | } |
--- src/sys/compat/linux/common/linux_exec.h 2014/02/09 16:41:42 1.50
+++ src/sys/compat/linux/common/linux_exec.h 2014/02/21 07:53:53 1.51
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: linux_exec.h,v 1.50 2014/02/09 16:41:42 chs Exp $ */ | 1 | /* $NetBSD: linux_exec.h,v 1.51 2014/02/21 07:53:53 maxv Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Frank van der Linden and Eric Haszlakiewicz. | 8 | * by Frank van der Linden and Eric Haszlakiewicz. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -72,26 +72,27 @@ | @@ -72,26 +72,27 @@ | |||
72 | #define LINUX_N_TXTADDR(x,m) ((m) == QMAGIC ? PAGE_SIZE : 0) | 72 | #define LINUX_N_TXTADDR(x,m) ((m) == QMAGIC ? PAGE_SIZE : 0) | |
73 | 73 | |||
74 | #define LINUX__N_SEGMENT_ROUND(x) (((x) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) | 74 | #define LINUX__N_SEGMENT_ROUND(x) (((x) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) | |
75 | 75 | |||
76 | #define LINUX__N_TXTENDADDR(x,m) (LINUX_N_TXTADDR(x,m)+(x).a_text) | 76 | #define LINUX__N_TXTENDADDR(x,m) (LINUX_N_TXTADDR(x,m)+(x).a_text) | |
77 | 77 | |||
78 | #define LINUX_N_DATADDR(x,m) \ | 78 | #define LINUX_N_DATADDR(x,m) \ | |
79 | ((m)==OMAGIC? (LINUX__N_TXTENDADDR(x,m)) \ | 79 | ((m)==OMAGIC? (LINUX__N_TXTENDADDR(x,m)) \ | |
80 | : (LINUX__N_SEGMENT_ROUND (LINUX__N_TXTENDADDR(x,m)))) | 80 | : (LINUX__N_SEGMENT_ROUND (LINUX__N_TXTENDADDR(x,m)))) | |
81 | 81 | |||
82 | #define LINUX_N_BSSADDR(x,m) (LINUX_N_DATADDR(x,m) + (x).a_data) | 82 | #define LINUX_N_BSSADDR(x,m) (LINUX_N_DATADDR(x,m) + (x).a_data) | |
83 | 83 | |||
84 | #ifndef LINUX_MACHDEP_ELF_COPYARGS | 84 | #ifndef LINUX_MACHDEP_ELF_COPYARGS | |
85 | /* Counted from linux_exec_elf32.c */ | |||
85 | #define LINUX_ELF_AUX_ENTRIES 14 | 86 | #define LINUX_ELF_AUX_ENTRIES 14 | |
86 | #endif | 87 | #endif | |
87 | 88 | |||
88 | /* | 89 | /* | |
89 | * From Linux's include/linux/elf.h | 90 | * From Linux's include/linux/elf.h | |
90 | */ | 91 | */ | |
91 | #define LINUX_AT_UID 11 /* real uid */ | 92 | #define LINUX_AT_UID 11 /* real uid */ | |
92 | #define LINUX_AT_EUID 12 /* effective uid */ | 93 | #define LINUX_AT_EUID 12 /* effective uid */ | |
93 | #define LINUX_AT_GID 13 /* real gid */ | 94 | #define LINUX_AT_GID 13 /* real gid */ | |
94 | #define LINUX_AT_EGID 14 /* effective gid */ | 95 | #define LINUX_AT_EGID 14 /* effective gid */ | |
95 | #define LINUX_AT_PLATFORM 15 /* CPU string for optimizations */ | 96 | #define LINUX_AT_PLATFORM 15 /* CPU string for optimizations */ | |
96 | #define LINUX_AT_HWCAP 16 /* arch dependent CPU capabilities */ | 97 | #define LINUX_AT_HWCAP 16 /* arch dependent CPU capabilities */ | |
97 | #define LINUX_AT_CLKTCK 17 /* frequency times() increments */ | 98 | #define LINUX_AT_CLKTCK 17 /* frequency times() increments */ |
--- src/sys/compat/linux/common/linux_exec_elf32.c 2014/02/09 16:41:42 1.88
+++ src/sys/compat/linux/common/linux_exec_elf32.c 2014/02/21 07:53:53 1.89
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: linux_exec_elf32.c,v 1.88 2014/02/09 16:41:42 chs Exp $ */ | 1 | /* $NetBSD: linux_exec_elf32.c,v 1.89 2014/02/21 07:53:53 maxv Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Christos Zoulas, Frank van der Linden, Eric Haszlakiewicz and | 8 | * by Christos Zoulas, Frank van der Linden, Eric Haszlakiewicz and | |
9 | * Emmanuel Dreyfus. | 9 | * Emmanuel Dreyfus. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | /* | 33 | /* | |
34 | * based on exec_aout.c, sunos_exec.c and svr4_exec.c | 34 | * based on exec_aout.c, sunos_exec.c and svr4_exec.c | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.88 2014/02/09 16:41:42 chs Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.89 2014/02/21 07:53:53 maxv Exp $"); | |
39 | 39 | |||
40 | #ifndef ELFSIZE | 40 | #ifndef ELFSIZE | |
41 | /* XXX should die */ | 41 | /* XXX should die */ | |
42 | #define ELFSIZE 32 | 42 | #define ELFSIZE 32 | |
43 | #endif | 43 | #endif | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | #include <sys/kernel.h> | 47 | #include <sys/kernel.h> | |
48 | #include <sys/proc.h> | 48 | #include <sys/proc.h> | |
49 | #include <sys/malloc.h> | 49 | #include <sys/malloc.h> | |
50 | #include <sys/namei.h> | 50 | #include <sys/namei.h> | |
51 | #include <sys/vnode.h> | 51 | #include <sys/vnode.h> | |
@@ -485,20 +485,21 @@ ELFNAME2(linux,copyargs)(struct lwp *l, | @@ -485,20 +485,21 @@ ELFNAME2(linux,copyargs)(struct lwp *l, | |||
485 | a++; | 485 | a++; | |
486 | 486 | |||
487 | randbytes[0] = cprng_strong32(); | 487 | randbytes[0] = cprng_strong32(); | |
488 | randbytes[1] = cprng_strong32(); | 488 | randbytes[1] = cprng_strong32(); | |
489 | randbytes[2] = cprng_strong32(); | 489 | randbytes[2] = cprng_strong32(); | |
490 | randbytes[3] = cprng_strong32(); | 490 | randbytes[3] = cprng_strong32(); | |
491 | 491 | |||
492 | len = sizeof(randbytes); | 492 | len = sizeof(randbytes); | |
493 | if ((error = copyout(randbytes, *stackp, len)) != 0) | 493 | if ((error = copyout(randbytes, *stackp, len)) != 0) | |
494 | return error; | 494 | return error; | |
495 | *stackp += len; | 495 | *stackp += len; | |
496 | 496 | |||
497 | len = (a - ai) * sizeof(AuxInfo); | 497 | len = (a - ai) * sizeof(AuxInfo); | |
498 | KASSERT(len <= LINUX_ELF_AUX_ENTRIES); | |||
498 | if ((error = copyout(ai, *stackp, len)) != 0) | 499 | if ((error = copyout(ai, *stackp, len)) != 0) | |
499 | return error; | 500 | return error; | |
500 | *stackp += len; | 501 | *stackp += len; | |
501 | 502 | |||
502 | return 0; | 503 | return 0; | |
503 | } | 504 | } | |
504 | #endif /* !LINUX_MACHDEP_ELF_COPYARGS */ | 505 | #endif /* !LINUX_MACHDEP_ELF_COPYARGS */ |
--- src/sys/compat/linux32/arch/amd64/linux32_exec.h 2014/02/09 16:41:42 1.5
+++ src/sys/compat/linux32/arch/amd64/linux32_exec.h 2014/02/21 07:53:53 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: linux32_exec.h,v 1.5 2014/02/09 16:41:42 chs Exp $ */ | 1 | /* $NetBSD: linux32_exec.h,v 1.6 2014/02/21 07:53:53 maxv Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. | 4 | * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * 3. All advertising materials mentioning features or use of this software | 14 | * 3. All advertising materials mentioning features or use of this software | |
@@ -31,27 +31,28 @@ | @@ -31,27 +31,28 @@ | |||
31 | * POSSIBILITY OF SUCH DAMAGE. | 31 | * POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | #ifndef _AMD64_LINUX32_EXEC_H | 33 | #ifndef _AMD64_LINUX32_EXEC_H | |
34 | #define _AMD64_LINUX32_EXEC_H | 34 | #define _AMD64_LINUX32_EXEC_H | |
35 | 35 | |||
36 | #include <sys/exec_elf.h> | 36 | #include <sys/exec_elf.h> | |
37 | 37 | |||
38 | #define LINUX32_M_I386 100 | 38 | #define LINUX32_M_I386 100 | |
39 | #define LINUX32_MID_MACHINE LINUX_M_I386 | 39 | #define LINUX32_MID_MACHINE LINUX_M_I386 | |
40 | #define LINUX32_USRSTACK 0xC0000000 | 40 | #define LINUX32_USRSTACK 0xC0000000 | |
41 | 41 | |||
42 | #define LINUX32_DEBUGLINK_SIGNATURE 1 | 42 | #define LINUX32_DEBUGLINK_SIGNATURE 1 | |
43 | 43 | |||
44 | #define LINUX32_ELF_AUX_ENTRIES 14 | 44 | /* Counted from common/linux32_exec_elf32.c */ | |
45 | #define LINUX32_ELF_AUX_ENTRIES 15 | |||
45 | 46 | |||
46 | #define LINUX32_RANDOM_BYTES 16 /* 16 bytes for AT_RANDOM */ | 47 | #define LINUX32_RANDOM_BYTES 16 /* 16 bytes for AT_RANDOM */ | |
47 | 48 | |||
48 | #if 0 | 49 | #if 0 | |
49 | 50 | |||
50 | /* Hardware platform identifier string */ | 51 | /* Hardware platform identifier string */ | |
51 | #define LINUX32_PLATFORM "i686" | 52 | #define LINUX32_PLATFORM "i686" | |
52 | 53 | |||
53 | #define LINUX32_CPUCAP (cpu_feature[0]) | 54 | #define LINUX32_CPUCAP (cpu_feature[0]) | |
54 | 55 | |||
55 | /* vsyscall assembly */ | 56 | /* vsyscall assembly */ | |
56 | static char linux32_kernel_vsyscall[] = { | 57 | static char linux32_kernel_vsyscall[] = { | |
57 | 0x55, /* push %ebp */ \ | 58 | 0x55, /* push %ebp */ \ |
--- src/sys/compat/linux32/common/linux32_exec_elf32.c 2014/02/09 16:41:42 1.14
+++ src/sys/compat/linux32/common/linux32_exec_elf32.c 2014/02/21 07:53:53 1.15
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: linux32_exec_elf32.c,v 1.14 2014/02/09 16:41:42 chs Exp $ */ | 1 | /* $NetBSD: linux32_exec_elf32.c,v 1.15 2014/02/21 07:53:53 maxv Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1995, 1998, 2000, 2001,2006 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1995, 1998, 2000, 2001,2006 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Christos Zoulas, Frank van der Linden, Eric Haszlakiewicz and | 8 | * by Christos Zoulas, Frank van der Linden, Eric Haszlakiewicz and | |
9 | * Emmanuel Dreyfus. | 9 | * Emmanuel Dreyfus. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | __KERNEL_RCSID(0, "$NetBSD: linux32_exec_elf32.c,v 1.14 2014/02/09 16:41:42 chs Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: linux32_exec_elf32.c,v 1.15 2014/02/21 07:53:53 maxv Exp $"); | |
35 | 35 | |||
36 | #define ELFSIZE 32 | 36 | #define ELFSIZE 32 | |
37 | 37 | |||
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | #include <sys/systm.h> | 39 | #include <sys/systm.h> | |
40 | #include <sys/proc.h> | 40 | #include <sys/proc.h> | |
41 | #include <sys/vnode.h> | 41 | #include <sys/vnode.h> | |
42 | #include <sys/exec.h> | 42 | #include <sys/exec.h> | |
43 | #include <sys/exec_elf.h> | 43 | #include <sys/exec_elf.h> | |
44 | #include <sys/kauth.h> | 44 | #include <sys/kauth.h> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
46 | #include <sys/resourcevar.h> | 46 | #include <sys/resourcevar.h> | |
47 | #include <sys/signal.h> | 47 | #include <sys/signal.h> | |
@@ -181,26 +181,28 @@ linux32_elf32_copyargs(struct lwp *l, st | @@ -181,26 +181,28 @@ linux32_elf32_copyargs(struct lwp *l, st | |||
181 | a->a_v = ((vap->va_mode & S_ISGID) ? | 181 | a->a_v = ((vap->va_mode & S_ISGID) ? | |
182 | vap->va_gid : kauth_cred_getegid(l->l_cred)); | 182 | vap->va_gid : kauth_cred_getegid(l->l_cred)); | |
183 | a++; | 183 | a++; | |
184 | 184 | |||
185 | a->a_type = LINUX_AT_SECURE; | 185 | a->a_type = LINUX_AT_SECURE; | |
186 | a->a_v = 0; | 186 | a->a_v = 0; | |
187 | a++; | 187 | a++; | |
188 | 188 | |||
189 | a->a_type = LINUX_AT_RANDOM; | 189 | a->a_type = LINUX_AT_RANDOM; | |
190 | a->a_v = NETBSD32PTR32I(*stackp); | 190 | a->a_v = NETBSD32PTR32I(*stackp); | |
191 | a++; | 191 | a++; | |
192 | 192 | |||
193 | #if 0 | 193 | #if 0 | |
194 | /* XXX: increase LINUX32_ELF_AUX_ENTRIES if we enable those things */ | |||
195 | ||||
194 | a->a_type = LINUX_AT_SYSINFO; | 196 | a->a_type = LINUX_AT_SYSINFO; | |
195 | a->a_v = NETBSD32PTR32I(&esdp->kernel_vsyscall[0]); | 197 | a->a_v = NETBSD32PTR32I(&esdp->kernel_vsyscall[0]); | |
196 | a++; | 198 | a++; | |
197 | 199 | |||
198 | a->a_type = LINUX_AT_SYSINFO_EHDR; | 200 | a->a_type = LINUX_AT_SYSINFO_EHDR; | |
199 | a->a_v = NETBSD32PTR32I(&esdp->elfhdr); | 201 | a->a_v = NETBSD32PTR32I(&esdp->elfhdr); | |
200 | a++; | 202 | a++; | |
201 | 203 | |||
202 | a->a_type = LINUX_AT_HWCAP; | 204 | a->a_type = LINUX_AT_HWCAP; | |
203 | a->a_v = LINUX32_CPUCAP; | 205 | a->a_v = LINUX32_CPUCAP; | |
204 | a++; | 206 | a++; | |
205 | 207 | |||
206 | a->a_type = LINUX_AT_PLATFORM; | 208 | a->a_type = LINUX_AT_PLATFORM; | |
@@ -229,19 +231,20 @@ linux32_elf32_copyargs(struct lwp *l, st | @@ -229,19 +231,20 @@ linux32_elf32_copyargs(struct lwp *l, st | |||
229 | memcpy(&esd.elfhdr, eh, sizeof(*eh)); | 231 | memcpy(&esd.elfhdr, eh, sizeof(*eh)); | |
230 | 232 | |||
231 | strcpy(esd.hw_platform, LINUX32_PLATFORM); | 233 | strcpy(esd.hw_platform, LINUX32_PLATFORM); | |
232 | 234 | |||
233 | /* | 235 | /* | |
234 | * Copy out the ELF auxiliary table and hw platform name | 236 | * Copy out the ELF auxiliary table and hw platform name | |
235 | */ | 237 | */ | |
236 | if ((error = copyout(&esd, esdp, sizeof(esd))) != 0) | 238 | if ((error = copyout(&esd, esdp, sizeof(esd))) != 0) | |
237 | return error; | 239 | return error; | |
238 | *stackp += sizeof(esd); | 240 | *stackp += sizeof(esd); | |
239 | #endif | 241 | #endif | |
240 | 242 | |||
241 | len = (a - ai) * sizeof(AuxInfo); | 243 | len = (a - ai) * sizeof(AuxInfo); | |
244 | KASSERT(len <= LINUX32_ELF_AUX_ENTRIES); | |||
242 | if ((error = copyout(ai, *stackp, len)) != 0) | 245 | if ((error = copyout(ai, *stackp, len)) != 0) | |
243 | return error; | 246 | return error; | |
244 | *stackp += len; | 247 | *stackp += len; | |
245 | 248 | |||
246 | return 0; | 249 | return 0; | |
247 | } | 250 | } |