Module Name:    src
Committed By:   kamil
Date:           Wed Mar 29 22:48:03 UTC 2017

Modified Files:
        src/sys/kern: core_elf32.c sys_ptrace_common.c

Log Message:
Revert previous.

Pointed out by Christous Zoulas that ELF_AUX_ENTRIES * sizeof(AuxInfo)
assumption is incomplete. There is emulation code that can use different
values (smaller and larger).


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/kern/core_elf32.c
cvs rdiff -u -r1.19 -r1.20 src/sys/kern/sys_ptrace_common.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/core_elf32.c
diff -u src/sys/kern/core_elf32.c:1.52 src/sys/kern/core_elf32.c:1.53
--- src/sys/kern/core_elf32.c:1.52	Wed Mar 29 19:52:30 2017
+++ src/sys/kern/core_elf32.c	Wed Mar 29 22:48:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: core_elf32.c,v 1.52 2017/03/29 19:52:30 kamil Exp $	*/
+/*	$NetBSD: core_elf32.c,v 1.53 2017/03/29 22:48:03 kamil Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.52 2017/03/29 19:52:30 kamil Exp $");
+__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.53 2017/03/29 22:48:03 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_coredump.h"
@@ -416,7 +416,7 @@ coredump_note_auxv(struct lwp *l, struct
 
 	size_t ptrsz = PROC_PTRSZ(p);
 	uauxv = (void *)((char *)pss.ps_envstr + (pss.ps_nenvstr + 1) * ptrsz);
-	size_t len = ELF_AUX_ENTRIES * sizeof(AuxInfo);
+	size_t len = p->p_execsw->es_arglen;
 
 	kauxv = kmem_alloc(len, KM_SLEEP);
 	error = copyin_proc(p, uauxv, kauxv, len);

Index: src/sys/kern/sys_ptrace_common.c
diff -u src/sys/kern/sys_ptrace_common.c:1.19 src/sys/kern/sys_ptrace_common.c:1.20
--- src/sys/kern/sys_ptrace_common.c:1.19	Wed Mar 29 19:52:30 2017
+++ src/sys/kern/sys_ptrace_common.c	Wed Mar 29 22:48:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_ptrace_common.c,v 1.19 2017/03/29 19:52:30 kamil Exp $	*/
+/*	$NetBSD: sys_ptrace_common.c,v 1.20 2017/03/29 22:48:03 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.19 2017/03/29 19:52:30 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.20 2017/03/29 22:48:03 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -129,7 +129,6 @@ __KERNEL_RCSID(0, "$NetBSD: sys_ptrace_c
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/proc.h>
-#include <sys/exec_elf.h>
 #include <sys/errno.h>
 #include <sys/exec.h>
 #include <sys/pax.h>
@@ -625,7 +624,7 @@ do_ptrace(struct ptrace_methods *ptm, st
 		case PIOD_READ_AUXV:
 			req = PT_READ_D;
 			uio.uio_rw = UIO_READ;
-			tmp = ELF_AUX_ENTRIES * sizeof(AuxInfo);
+			tmp = t->p_execsw->es_arglen;
 			if (uio.uio_offset > tmp)
 				return EIO;
 			if (uio.uio_resid > tmp - uio.uio_offset)

Reply via email to