Module Name: src
Committed By: christos
Date: Mon Jun 24 20:29:41 UTC 2019
Modified Files:
src/sys/kern: sys_ptrace_common.c
Log Message:
the tracer, not the tracee determine if we are going to convert the ptrace
data from 64 to 32.
To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 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.55 src/sys/kern/sys_ptrace_common.c:1.56
--- src/sys/kern/sys_ptrace_common.c:1.55 Tue Jun 11 19:18:55 2019
+++ src/sys/kern/sys_ptrace_common.c Mon Jun 24 16:29:41 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_ptrace_common.c,v 1.55 2019/06/11 23:18:55 kamil Exp $ */
+/* $NetBSD: sys_ptrace_common.c,v 1.56 2019/06/24 20:29:41 christos 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.55 2019/06/11 23:18:55 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.56 2019/06/24 20:29:41 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_ptrace.h"
@@ -1483,9 +1483,13 @@ process_doregs(struct lwp *curl /*tracer
regwfunc_t w;
#ifdef COMPAT_NETBSD32
- const bool pk32 = (l->l_proc->p_flag & PK_32) != 0;
+ const bool pk32 = (curl->l_proc->p_flag & PK_32) != 0;
if (__predict_false(pk32)) {
+ if ((l->l_proc->p_flag & PK_32) == 0) {
+ // 32 bit tracer can't trace 64 bit process
+ return EINVAL;
+ }
s = sizeof(process_reg32);
r = (regrfunc_t)process_read_regs32;
w = (regwfunc_t)process_write_regs32;
@@ -1524,9 +1528,13 @@ process_dofpregs(struct lwp *curl /*trac
regwfunc_t w;
#ifdef COMPAT_NETBSD32
- const bool pk32 = (l->l_proc->p_flag & PK_32) != 0;
+ const bool pk32 = (curl->l_proc->p_flag & PK_32) != 0;
if (__predict_false(pk32)) {
+ if ((l->l_proc->p_flag & PK_32) == 0) {
+ // 32 bit tracer can't trace 64 bit process
+ return EINVAL;
+ }
s = sizeof(process_fpreg32);
r = (regrfunc_t)process_read_fpregs32;
w = (regwfunc_t)process_write_fpregs32;
@@ -1565,9 +1573,13 @@ process_dodbregs(struct lwp *curl /*trac
regwfunc_t w;
#ifdef COMPAT_NETBSD32
- const bool pk32 = (l->l_proc->p_flag & PK_32) != 0;
+ const bool pk32 = (curl->l_proc->p_flag & PK_32) != 0;
if (__predict_false(pk32)) {
+ if ((l->l_proc->p_flag & PK_32) == 0) {
+ // 32 bit tracer can't trace 64 bit process
+ return EINVAL;
+ }
s = sizeof(process_dbreg32);
r = (regrfunc_t)process_read_dbregs32;
w = (regwfunc_t)process_write_dbregs32;