Introduce and use PROC_PTRSZ() to handle differing pointer size 64->32
emulation.
This commit is contained in:
parent
36f0250a07
commit
e771ba939e
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: core_elf32.c,v 1.48 2016/09/05 17:42:57 dholland Exp $ */
|
||||
/* $NetBSD: core_elf32.c,v 1.49 2016/09/29 20:40:53 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||
@ -40,7 +40,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.48 2016/09/05 17:42:57 dholland Exp $");
|
||||
__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.49 2016/09/29 20:40:53 christos Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_coredump.h"
|
||||
@ -407,7 +407,6 @@ coredump_note_auxv(struct lwp *l, struct note_state *ns)
|
||||
int error;
|
||||
struct proc *p = l->l_proc;
|
||||
void *uauxv, *kauxv;
|
||||
size_t len;
|
||||
|
||||
if ((error = copyin_psstrings(p, &pss)) != 0)
|
||||
return error;
|
||||
@ -415,18 +414,9 @@ coredump_note_auxv(struct lwp *l, struct note_state *ns)
|
||||
if (pss.ps_envstr == NULL)
|
||||
return EIO;
|
||||
|
||||
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 *);
|
||||
}
|
||||
size_t ptrsz = PROC_PTRSZ(p);
|
||||
uauxv = (void *)((char *)pss.ps_envstr + (pss.ps_nenvstr + 1) * ptrsz);
|
||||
size_t len = p->p_execsw->es_arglen * ptrsz;
|
||||
|
||||
kauxv = kmem_alloc(len, KM_SLEEP);
|
||||
error = copyin_proc(p, uauxv, kauxv, len);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_proc.c,v 1.197 2016/09/17 12:00:34 maxv Exp $ */
|
||||
/* $NetBSD: kern_proc.c,v 1.198 2016/09/29 20:40:53 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -62,7 +62,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.197 2016/09/17 12:00:34 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.198 2016/09/29 20:40:53 christos Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_kstack.h"
|
||||
@ -2052,12 +2052,6 @@ copy_procargs(struct proc *p, int oid, size_t *limit,
|
||||
goto done;
|
||||
}
|
||||
|
||||
#ifdef COMPAT_NETBSD32
|
||||
if (p->p_flag & PK_32)
|
||||
entry_len = sizeof(netbsd32_charp);
|
||||
else
|
||||
#endif
|
||||
entry_len = sizeof(char *);
|
||||
|
||||
/*
|
||||
* Now copy each string.
|
||||
@ -2065,6 +2059,7 @@ copy_procargs(struct proc *p, int oid, size_t *limit,
|
||||
len = 0; /* bytes written to user buffer */
|
||||
loaded = 0; /* bytes from argv already processed */
|
||||
i = 0; /* To make compiler happy */
|
||||
entry_len = PROC_PTRSZ(p);
|
||||
|
||||
for (; argvlen; --argvlen) {
|
||||
int finished = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sys_process.c,v 1.169 2016/05/25 17:43:58 christos Exp $ */
|
||||
/* $NetBSD: sys_process.c,v 1.170 2016/09/29 20:40:53 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
|
||||
@ -118,7 +118,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.169 2016/05/25 17:43:58 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.170 2016/09/29 20:40:53 christos Exp $");
|
||||
|
||||
#include "opt_ptrace.h"
|
||||
#include "opt_ktrace.h"
|
||||
@ -563,7 +563,7 @@ sys_ptrace(struct lwp *l, const struct sys_ptrace_args *uap, register_t *retval)
|
||||
case PIOD_READ_AUXV:
|
||||
req = PT_READ_D;
|
||||
uio.uio_rw = UIO_READ;
|
||||
tmp = t->p_execsw->es_arglen * sizeof(char *);
|
||||
tmp = t->p_execsw->es_arglen * PROC_PTRSZ(t);
|
||||
if (uio.uio_offset > tmp)
|
||||
return EIO;
|
||||
if (uio.uio_resid > tmp - uio.uio_offset)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: proc.h,v 1.333 2016/09/23 14:09:39 skrll Exp $ */
|
||||
/* $NetBSD: proc.h,v 1.334 2016/09/29 20:40:53 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -556,6 +556,8 @@ _proclist_skipmarker(struct proc *p0)
|
||||
return p;
|
||||
}
|
||||
|
||||
#define PROC_PTRSZ(p) (((p)->p_flag & PK_32) ? sizeof(int) : sizeof(void *))
|
||||
|
||||
/*
|
||||
* PROCLIST_FOREACH: iterate on the given proclist, skipping PK_MARKER ones.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user