Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Fix pointer arithmetic for 32-bit process on LP64 k...



details:   https://anonhg.NetBSD.org/src/rev/6b09e79e54dd
branches:  trunk
changeset: 461150:6b09e79e54dd
user:      rin <rin%NetBSD.org@localhost>
date:      Sun Nov 17 02:22:14 2019 +0000

description:
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

diffstat:

 sys/kern/sys_ptrace_common.c |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r 002cfa147804 -r 6b09e79e54dd sys/kern/sys_ptrace_common.c
--- a/sys/kern/sys_ptrace_common.c      Sat Nov 16 22:51:51 2019 +0000
+++ b/sys/kern/sys_ptrace_common.c      Sun Nov 17 02:22:14 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_ptrace_common.c,v 1.71 2019/11/13 15:48:36 pgoyette Exp $  */
+/*     $NetBSD: sys_ptrace_common.c,v 1.72 2019/11/17 02:22:14 rin 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.71 2019/11/13 15:48:36 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.72 2019/11/17 02:22:14 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -1635,7 +1635,15 @@
        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;



Home | Main Index | Thread Index | Old Index