Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Define ELF_MAXNOTESIZE, ELF_MAXSHNUM and ELF_MAXPHNUM in...
details: https://anonhg.NetBSD.org/src/rev/09748c118ec8
branches: trunk
changeset: 330431:09748c118ec8
user: maxv <maxv%NetBSD.org@localhost>
date: Tue Jul 08 17:16:25 2014 +0000
description:
Define ELF_MAXNOTESIZE, ELF_MAXSHNUM and ELF_MAXPHNUM in <sys/exec_elf.h>, so
that it can be used externally.
diffstat:
sys/kern/exec_elf.c | 21 +++++++--------------
sys/sys/exec_elf.h | 9 ++++++++-
2 files changed, 15 insertions(+), 15 deletions(-)
diffs (97 lines):
diff -r bd2b392ccf7f -r 09748c118ec8 sys/kern/exec_elf.c
--- a/sys/kern/exec_elf.c Tue Jul 08 17:15:14 2014 +0000
+++ b/sys/kern/exec_elf.c Tue Jul 08 17:16:25 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_elf.c,v 1.68 2014/07/06 07:41:41 maxv Exp $ */
+/* $NetBSD: exec_elf.c,v 1.69 2014/07/08 17:16:25 maxv Exp $ */
/*-
* Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.68 2014/07/06 07:41:41 maxv Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.69 2014/07/08 17:16:25 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_pax.h"
@@ -115,13 +115,6 @@
#define ELF_ROUND(a, b) (((a) + (b) - 1) & ~((b) - 1))
#define ELF_TRUNC(a, b) ((a) & ~((b) - 1))
-/*
- * Arbitrary limits to avoid DoS for excessive memory allocation.
- */
-#define MAXPHNUM 128
-#define MAXSHNUM 32768
-#define MAXNOTESIZE 1024
-
static void
elf_placedynexec(struct lwp *l, struct exec_package *epp, Elf_Ehdr *eh,
Elf_Phdr *ph)
@@ -304,7 +297,7 @@
if (ELF_EHDR_FLAGS_OK(eh) == 0)
return ENOEXEC;
- if (eh->e_shnum > MAXSHNUM || eh->e_phnum > MAXPHNUM)
+ if (eh->e_shnum > ELF_MAXSHNUM || eh->e_phnum > ELF_MAXPHNUM)
return ENOEXEC;
return 0;
@@ -882,7 +875,7 @@
#endif
epp->ep_pax_flags = 0;
- if (eh->e_shnum > MAXSHNUM || eh->e_shnum == 0)
+ if (eh->e_shnum > ELF_MAXSHNUM || eh->e_shnum == 0)
return ENOEXEC;
shsize = eh->e_shnum * sizeof(Elf_Shdr);
@@ -891,12 +884,12 @@
if (error)
goto out;
- np = kmem_alloc(MAXNOTESIZE, KM_SLEEP);
+ np = kmem_alloc(ELF_MAXNOTESIZE, KM_SLEEP);
for (i = 0; i < eh->e_shnum; i++) {
Elf_Shdr *shp = &sh[i];
if (shp->sh_type != SHT_NOTE ||
- shp->sh_size > MAXNOTESIZE ||
+ shp->sh_size > ELF_MAXNOTESIZE ||
shp->sh_size < sizeof(Elf_Nhdr) + ELF_NOTE_NETBSD_NAMESZ)
continue;
@@ -1035,7 +1028,7 @@
break;
}
}
- kmem_free(np, MAXNOTESIZE);
+ kmem_free(np, ELF_MAXNOTESIZE);
error = isnetbsd ? 0 : ENOEXEC;
out:
diff -r bd2b392ccf7f -r 09748c118ec8 sys/sys/exec_elf.h
--- a/sys/sys/exec_elf.h Tue Jul 08 17:15:14 2014 +0000
+++ b/sys/sys/exec_elf.h Tue Jul 08 17:16:25 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_elf.h,v 1.140 2014/03/09 17:59:19 christos Exp $ */
+/* $NetBSD: exec_elf.h,v 1.141 2014/07/08 17:16:25 maxv Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -1225,6 +1225,13 @@
#ifdef _KERNEL
+/*
+ * Arbitrary limits to avoid DoS for excessive memory allocation.
+ */
+#define ELF_MAXPHNUM 128
+#define ELF_MAXSHNUM 32768
+#define ELF_MAXNOTESIZE 1024
+
#define ELF_AUX_ENTRIES 15 /* Max size of aux array passed to loader */
#define ELF32_NO_ADDR (~(Elf32_Addr)0) /* Indicates addr. not yet filled in */
#define ELF32_LINK_ADDR ((Elf32_Addr)-2) /* advises to use link address */
Home |
Main Index |
Thread Index |
Old Index