| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: sys_ptrace_common.c,v 1.4 2016/11/12 20:03:17 christos Exp $ */ | | 1 | /* $NetBSD: sys_ptrace_common.c,v 1.5 2016/11/19 19:06:12 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Andrew Doran. | | 8 | * by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -108,27 +108,27 @@ | | | @@ -108,27 +108,27 @@ |
108 | | | 108 | |
109 | /* | | 109 | /* |
110 | * References: | | 110 | * References: |
111 | * (1) Bach's "The Design of the UNIX Operating System", | | 111 | * (1) Bach's "The Design of the UNIX Operating System", |
112 | * (2) sys/miscfs/procfs from UCB's 4.4BSD-Lite distribution, | | 112 | * (2) sys/miscfs/procfs from UCB's 4.4BSD-Lite distribution, |
113 | * (3) the "4.4BSD Programmer's Reference Manual" published | | 113 | * (3) the "4.4BSD Programmer's Reference Manual" published |
114 | * by USENIX and O'Reilly & Associates. | | 114 | * by USENIX and O'Reilly & Associates. |
115 | * The 4.4BSD PRM does a reasonably good job of documenting what the various | | 115 | * The 4.4BSD PRM does a reasonably good job of documenting what the various |
116 | * ptrace() requests should actually do, and its text is quoted several times | | 116 | * ptrace() requests should actually do, and its text is quoted several times |
117 | * in this file. | | 117 | * in this file. |
118 | */ | | 118 | */ |
119 | | | 119 | |
120 | #include <sys/cdefs.h> | | 120 | #include <sys/cdefs.h> |
121 | __KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.4 2016/11/12 20:03:17 christos Exp $"); | | 121 | __KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.5 2016/11/19 19:06:12 christos Exp $"); |
122 | | | 122 | |
123 | #ifdef _KERNEL_OPT | | 123 | #ifdef _KERNEL_OPT |
124 | #include "opt_ptrace.h" | | 124 | #include "opt_ptrace.h" |
125 | #include "opt_ktrace.h" | | 125 | #include "opt_ktrace.h" |
126 | #include "opt_pax.h" | | 126 | #include "opt_pax.h" |
127 | #endif | | 127 | #endif |
128 | | | 128 | |
129 | #include <sys/param.h> | | 129 | #include <sys/param.h> |
130 | #include <sys/systm.h> | | 130 | #include <sys/systm.h> |
131 | #include <sys/proc.h> | | 131 | #include <sys/proc.h> |
132 | #include <sys/errno.h> | | 132 | #include <sys/errno.h> |
133 | #include <sys/exec.h> | | 133 | #include <sys/exec.h> |
134 | #include <sys/pax.h> | | 134 | #include <sys/pax.h> |
| @@ -935,26 +935,27 @@ do_ptrace(struct ptrace_methods *ptm, st | | | @@ -935,26 +935,27 @@ do_ptrace(struct ptrace_methods *ptm, st |
935 | uio.uio_resid = iov.iov_len; | | 935 | uio.uio_resid = iov.iov_len; |
936 | uio.uio_rw = write ? UIO_WRITE : UIO_READ; | | 936 | uio.uio_rw = write ? UIO_WRITE : UIO_READ; |
937 | uio.uio_vmspace = vm; | | 937 | uio.uio_vmspace = vm; |
938 | | | 938 | |
939 | error = ptm->ptm_doregs(l, lt, &uio); | | 939 | error = ptm->ptm_doregs(l, lt, &uio); |
940 | uvmspace_free(vm); | | 940 | uvmspace_free(vm); |
941 | } | | 941 | } |
942 | break; | | 942 | break; |
943 | #endif | | 943 | #endif |
944 | | | 944 | |
945 | #ifdef PT_SETFPREGS | | 945 | #ifdef PT_SETFPREGS |
946 | case PT_SETFPREGS: | | 946 | case PT_SETFPREGS: |
947 | write = 1; | | 947 | write = 1; |
| | | 948 | /*FALLTHROUGH*/ |
948 | #endif | | 949 | #endif |
949 | #ifdef PT_GETFPREGS | | 950 | #ifdef PT_GETFPREGS |
950 | case PT_GETFPREGS: | | 951 | case PT_GETFPREGS: |
951 | /* write = 0 done above. */ | | 952 | /* write = 0 done above. */ |
952 | #endif | | 953 | #endif |
953 | #if defined(PT_SETFPREGS) || defined(PT_GETFPREGS) | | 954 | #if defined(PT_SETFPREGS) || defined(PT_GETFPREGS) |
954 | tmp = data; | | 955 | tmp = data; |
955 | if (tmp != 0 && t->p_nlwps > 1) { | | 956 | if (tmp != 0 && t->p_nlwps > 1) { |
956 | lwp_delref(lt); | | 957 | lwp_delref(lt); |
957 | mutex_enter(t->p_lock); | | 958 | mutex_enter(t->p_lock); |
958 | lt = lwp_find(t, tmp); | | 959 | lt = lwp_find(t, tmp); |
959 | if (lt == NULL) { | | 960 | if (lt == NULL) { |
960 | mutex_exit(t->p_lock); | | 961 | mutex_exit(t->p_lock); |