Module Name:    src
Committed By:   christos
Date:           Mon Jun 27 01:46:04 UTC 2016

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

Log Message:
PR/51277: Fix compat32 coredumping that broke with the aux vector note
addition.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/kern/core_elf32.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.46 src/sys/kern/core_elf32.c:1.47
--- src/sys/kern/core_elf32.c:1.46	Mon May 23 20:49:56 2016
+++ src/sys/kern/core_elf32.c	Sun Jun 26 21:46:04 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: core_elf32.c,v 1.46 2016/05/24 00:49:56 christos Exp $	*/
+/*	$NetBSD: core_elf32.c,v 1.47 2016/06/27 01:46:04 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,10 +40,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.46 2016/05/24 00:49:56 christos Exp $");
+__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.47 2016/06/27 01:46:04 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_coredump.h"
+#include "opt_compat_netbsd32.h"
 #endif
 
 #ifndef ELFSIZE
@@ -405,7 +406,6 @@ coredump_note_auxv(struct lwp *l, struct
 	struct ps_strings pss;
 	int error;
 	struct proc *p = l->l_proc;
-	struct vmspace *vm;
 	void *uauxv, *kauxv;
 	size_t len;
 
@@ -415,16 +415,21 @@ coredump_note_auxv(struct lwp *l, struct
 	if (pss.ps_envstr == NULL)
 		return EIO;
 
-        vm = p->p_vmspace;
-	uvmspace_addref(vm);
+	len = p->p_execsw->es_arglen;
+#ifdef COMPAT_NETBSD32
+	if (p->p_flag & PK_32) {
+		uauxv = (void *)((char *)pss.ps_envstr
+		    + (pss.ps_nenvstr + 1) * sizeof(int32_t));
+		len *= sizeof(int32_t);
+	} else
+#endif
+	{
+		uauxv = (void *)(pss.ps_envstr + pss.ps_nenvstr + 1);
+		len *= sizeof(char *);
+	}
 
-	len = p->p_execsw->es_arglen * sizeof(char *);
-	uauxv = (void *)(pss.ps_envstr + pss.ps_nenvstr + 1);
 	kauxv = kmem_alloc(len, KM_SLEEP);
-	error = copyin_vmspace(vm, uauxv, kauxv, len);
-
-	uvmspace_free(vm);
-
+	error = copyin_proc(p, uauxv, kauxv, len);
 	if (error == 0) {
 		ELFNAMEEND(coredump_savenote)(ns, ELF_NOTE_NETBSD_CORE_AUXV,
 		    ELF_NOTE_NETBSD_CORE_NAME, kauxv, len);

Reply via email to