diff options
| author | maxv <maxv@NetBSD.org> | 2014-02-21 07:53:53 +0000 |
|---|---|---|
| committer | maxv <maxv@NetBSD.org> | 2014-02-21 07:53:53 +0000 |
| commit | d91ba50b1f2201f6aece5635388d036fdcd2b58b (patch) | |
| tree | ca42f6492c658263510e0dd53a3feca5b772e243 /sys/compat/linux | |
| parent | 2c728e7209ae0e0fe3fcf7b24c2a60499f85e66c (diff) | |
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@
Diffstat (limited to 'sys/compat/linux')
| -rw-r--r-- | sys/compat/linux/arch/amd64/linux_exec_machdep.c | 13 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_exec.h | 3 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_exec_elf32.c | 5 |
3 files changed, 9 insertions, 12 deletions
diff --git a/sys/compat/linux/arch/amd64/linux_exec_machdep.c b/sys/compat/linux/arch/amd64/linux_exec_machdep.c index f58b60b940e..3b83d5aedc7 100644 --- a/sys/compat/linux/arch/amd64/linux_exec_machdep.c +++ b/sys/compat/linux/arch/amd64/linux_exec_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec_machdep.c,v 1.20 2013/11/18 01:32:22 chs Exp $ */ +/* $NetBSD: linux_exec_machdep.c,v 1.21 2014/02/21 07:53:53 maxv 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.20 2013/11/18 01:32:22 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_exec_machdep.c,v 1.21 2014/02/21 07:53:53 maxv Exp $"); #define ELFSIZE 64 @@ -233,13 +233,8 @@ ELFNAME2(linux,copyargs)(struct lwp *l, struct exec_package *pack, esd.ai[i].a_type = AT_NULL; esd.ai[i++].a_v = 0; -#ifdef DEBUG_LINUX - if (i != LINUX_ELF_AUX_ENTRIES) { - printf("linux_elf64_copyargs: %d Aux entries\n", i); - return EINVAL; - } -#endif - + KASSERT(i == LINUX_ELF_AUX_ENTRIES); + strcpy(esd.hw_platform, LINUX_PLATFORM); exec_free_emul_arg(pack); diff --git a/sys/compat/linux/common/linux_exec.h b/sys/compat/linux/common/linux_exec.h index ac6018a8856..56a816ff136 100644 --- a/sys/compat/linux/common/linux_exec.h +++ b/sys/compat/linux/common/linux_exec.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec.h,v 1.50 2014/02/09 16:41:42 chs Exp $ */ +/* $NetBSD: linux_exec.h,v 1.51 2014/02/21 07:53:53 maxv Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -82,6 +82,7 @@ #define LINUX_N_BSSADDR(x,m) (LINUX_N_DATADDR(x,m) + (x).a_data) #ifndef LINUX_MACHDEP_ELF_COPYARGS +/* Counted from linux_exec_elf32.c */ #define LINUX_ELF_AUX_ENTRIES 14 #endif diff --git a/sys/compat/linux/common/linux_exec_elf32.c b/sys/compat/linux/common/linux_exec_elf32.c index 1d368e307c6..d1565017c0e 100644 --- a/sys/compat/linux/common/linux_exec_elf32.c +++ b/sys/compat/linux/common/linux_exec_elf32.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec_elf32.c,v 1.88 2014/02/09 16:41:42 chs Exp $ */ +/* $NetBSD: linux_exec_elf32.c,v 1.89 2014/02/21 07:53:53 maxv 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.88 2014/02/09 16:41:42 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.89 2014/02/21 07:53:53 maxv Exp $"); #ifndef ELFSIZE /* XXX should die */ @@ -495,6 +495,7 @@ ELFNAME2(linux,copyargs)(struct lwp *l, struct exec_package *pack, *stackp += len; len = (a - ai) * sizeof(AuxInfo); + KASSERT(len <= LINUX_ELF_AUX_ENTRIES); if ((error = copyout(ai, *stackp, len)) != 0) return error; *stackp += len; |
