Module Name:    src
Committed By:   martin
Date:           Tue Nov 19 10:50:26 UTC 2019

Modified Files:
        src/sys/kern [netbsd-8]: sys_ptrace_common.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #1452):

        sys/kern/sys_ptrace_common.c: revision 1.72

Fix pointer arithmetic for 32-bit process on LP64 kernel in
process_auxv_offset().

Now, PIOD_READ_AUXV works fine with COMPAT_NETBSD32.

XXX
pullup to netbsd-9 and netbsd-8


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.6 -r1.22.2.7 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/sys_ptrace_common.c
diff -u src/sys/kern/sys_ptrace_common.c:1.22.2.6 src/sys/kern/sys_ptrace_common.c:1.22.2.7
--- src/sys/kern/sys_ptrace_common.c:1.22.2.6	Sun Aug  4 11:05:29 2019
+++ src/sys/kern/sys_ptrace_common.c	Tue Nov 19 10:50:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_ptrace_common.c,v 1.22.2.6 2019/08/04 11:05:29 martin Exp $	*/
+/*	$NetBSD: sys_ptrace_common.c,v 1.22.2.7 2019/11/19 10:50:25 martin 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.22.2.6 2019/08/04 11:05:29 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.22.2.7 2019/11/19 10:50:25 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -1506,7 +1506,15 @@ process_auxv_offset(struct proc *p, stru
 	if (pss.ps_envstr == NULL)
 		return EIO;
 
-	uio->uio_offset += (off_t)(vaddr_t)(pss.ps_envstr + pss.ps_nenvstr + 1);
+#ifdef COMPAT_NETBSD32
+	if (p->p_flag & PK_32)
+		uio->uio_offset += (off_t)((vaddr_t)pss.ps_envstr +
+		    sizeof(uint32_t) * (pss.ps_nenvstr + 1));
+	else
+#endif
+		uio->uio_offset += (off_t)(vaddr_t)(pss.ps_envstr +
+		    pss.ps_nenvstr + 1);
+
 #ifdef __MACHINE_STACK_GROWS_UP
 	if (uio->uio_offset < off)
 		return EIO;

Reply via email to