Move ptrace's security policy back to the subsystem itself. Add a ptrace_init() so we have a place to register the listener; called next to ktrinit().diff -r1.403 -r1.404 src/sys/kern/init_main.c
(elad)
--- src/sys/kern/init_main.c 2009/10/02 18:50:14 1.403
+++ src/sys/kern/init_main.c 2009/10/02 22:18:57 1.404
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: init_main.c,v 1.403 2009/10/02 18:50:14 elad Exp $ */ | 1 | /* $NetBSD: init_main.c,v 1.404 2009/10/02 22:18:57 elad 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 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -87,41 +87,42 @@ | @@ -87,41 +87,42 @@ | |||
87 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 87 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
88 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 88 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
89 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 89 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
90 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 90 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
91 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 91 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
92 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 92 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
93 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 93 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
94 | * SUCH DAMAGE. | 94 | * SUCH DAMAGE. | |
95 | * | 95 | * | |
96 | * @(#)init_main.c 8.16 (Berkeley) 5/14/95 | 96 | * @(#)init_main.c 8.16 (Berkeley) 5/14/95 | |
97 | */ | 97 | */ | |
98 | 98 | |||
99 | #include <sys/cdefs.h> | 99 | #include <sys/cdefs.h> | |
100 | __KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.403 2009/10/02 18:50:14 elad Exp $"); | 100 | __KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.404 2009/10/02 22:18:57 elad Exp $"); | |
101 | 101 | |||
102 | #include "opt_ddb.h" | 102 | #include "opt_ddb.h" | |
103 | #include "opt_ipsec.h" | 103 | #include "opt_ipsec.h" | |
104 | #include "opt_modular.h" | 104 | #include "opt_modular.h" | |
105 | #include "opt_ntp.h" | 105 | #include "opt_ntp.h" | |
106 | #include "opt_pipe.h" | 106 | #include "opt_pipe.h" | |
107 | #include "opt_sa.h" | 107 | #include "opt_sa.h" | |
108 | #include "opt_syscall_debug.h" | 108 | #include "opt_syscall_debug.h" | |
109 | #include "opt_sysv.h" | 109 | #include "opt_sysv.h" | |
110 | #include "opt_fileassoc.h" | 110 | #include "opt_fileassoc.h" | |
111 | #include "opt_ktrace.h" | 111 | #include "opt_ktrace.h" | |
112 | #include "opt_pax.h" | 112 | #include "opt_pax.h" | |
113 | #include "opt_compat_netbsd.h" | 113 | #include "opt_compat_netbsd.h" | |
114 | #include "opt_wapbl.h" | 114 | #include "opt_wapbl.h" | |
115 | #include "opt_ptrace.h" | |||
115 | 116 | |||
116 | #include "drvctl.h" | 117 | #include "drvctl.h" | |
117 | #include "ksyms.h" | 118 | #include "ksyms.h" | |
118 | #include "rnd.h" | 119 | #include "rnd.h" | |
119 | #include "sysmon_envsys.h" | 120 | #include "sysmon_envsys.h" | |
120 | #include "sysmon_power.h" | 121 | #include "sysmon_power.h" | |
121 | #include "sysmon_taskq.h" | 122 | #include "sysmon_taskq.h" | |
122 | #include "sysmon_wdog.h" | 123 | #include "sysmon_wdog.h" | |
123 | #include "veriexec.h" | 124 | #include "veriexec.h" | |
124 | 125 | |||
125 | #include <sys/param.h> | 126 | #include <sys/param.h> | |
126 | #include <sys/acct.h> | 127 | #include <sys/acct.h> | |
127 | #include <sys/filedesc.h> | 128 | #include <sys/filedesc.h> | |
@@ -191,26 +192,29 @@ __KERNEL_RCSID(0, "$NetBSD: init_main.c, | @@ -191,26 +192,29 @@ __KERNEL_RCSID(0, "$NetBSD: init_main.c, | |||
191 | #include <sys/verified_exec.h> | 192 | #include <sys/verified_exec.h> | |
192 | #endif /* NVERIEXEC > 0 */ | 193 | #endif /* NVERIEXEC > 0 */ | |
193 | #ifdef KTRACE | 194 | #ifdef KTRACE | |
194 | #include <sys/ktrace.h> | 195 | #include <sys/ktrace.h> | |
195 | #endif | 196 | #endif | |
196 | #include <sys/kauth.h> | 197 | #include <sys/kauth.h> | |
197 | #ifdef WAPBL | 198 | #ifdef WAPBL | |
198 | #include <sys/wapbl.h> | 199 | #include <sys/wapbl.h> | |
199 | #endif | 200 | #endif | |
200 | #ifdef KERN_SA | 201 | #ifdef KERN_SA | |
201 | #include <sys/savar.h> | 202 | #include <sys/savar.h> | |
202 | #endif | 203 | #endif | |
203 | #include <net80211/ieee80211_netbsd.h> | 204 | #include <net80211/ieee80211_netbsd.h> | |
205 | #ifdef PTRACE | |||
206 | #include <sys/ptrace.h> | |||
207 | #endif /* PTRACE */ | |||
204 | 208 | |||
205 | #include <sys/syscall.h> | 209 | #include <sys/syscall.h> | |
206 | #include <sys/syscallargs.h> | 210 | #include <sys/syscallargs.h> | |
207 | 211 | |||
208 | #if defined(PAX_MPROTECT) || defined(PAX_SEGVGUARD) || defined(PAX_ASLR) | 212 | #if defined(PAX_MPROTECT) || defined(PAX_SEGVGUARD) || defined(PAX_ASLR) | |
209 | #include <sys/pax.h> | 213 | #include <sys/pax.h> | |
210 | #endif /* PAX_MPROTECT || PAX_SEGVGUARD || PAX_ASLR */ | 214 | #endif /* PAX_MPROTECT || PAX_SEGVGUARD || PAX_ASLR */ | |
211 | 215 | |||
212 | #include <ufs/ufs/quota.h> | 216 | #include <ufs/ufs/quota.h> | |
213 | 217 | |||
214 | #include <miscfs/genfs/genfs.h> | 218 | #include <miscfs/genfs/genfs.h> | |
215 | #include <miscfs/syncfs/syncfs.h> | 219 | #include <miscfs/syncfs/syncfs.h> | |
216 | 220 | |||
@@ -540,26 +544,31 @@ main(void) | @@ -540,26 +544,31 @@ main(void) | |||
540 | /* Initialize system accounting. */ | 544 | /* Initialize system accounting. */ | |
541 | acct_init(); | 545 | acct_init(); | |
542 | 546 | |||
543 | #ifndef PIPE_SOCKETPAIR | 547 | #ifndef PIPE_SOCKETPAIR | |
544 | /* Initialize pipes. */ | 548 | /* Initialize pipes. */ | |
545 | pipe_init(); | 549 | pipe_init(); | |
546 | #endif | 550 | #endif | |
547 | 551 | |||
548 | #ifdef KTRACE | 552 | #ifdef KTRACE | |
549 | /* Initialize ktrace. */ | 553 | /* Initialize ktrace. */ | |
550 | ktrinit(); | 554 | ktrinit(); | |
551 | #endif | 555 | #endif | |
552 | 556 | |||
557 | #ifdef PTRACE | |||
558 | /* Initialize ptrace. */ | |||
559 | ptrace_init(); | |||
560 | #endif /* PTRACE */ | |||
561 | ||||
553 | /* Initialize the UUID system calls. */ | 562 | /* Initialize the UUID system calls. */ | |
554 | uuid_init(); | 563 | uuid_init(); | |
555 | 564 | |||
556 | #ifdef WAPBL | 565 | #ifdef WAPBL | |
557 | /* Initialize write-ahead physical block logging. */ | 566 | /* Initialize write-ahead physical block logging. */ | |
558 | wapbl_init(); | 567 | wapbl_init(); | |
559 | #endif | 568 | #endif | |
560 | 569 | |||
561 | /* | 570 | /* | |
562 | * Create process 1 (init(8)). We do this now, as Unix has | 571 | * Create process 1 (init(8)). We do this now, as Unix has | |
563 | * historically had init be process 1, and changing this would | 572 | * historically had init be process 1, and changing this would | |
564 | * probably upset a lot of people. | 573 | * probably upset a lot of people. | |
565 | * | 574 | * |
--- src/sys/kern/sys_process.c 2009/06/28 11:42:07 1.147
+++ src/sys/kern/sys_process.c 2009/10/02 22:18:57 1.148
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: sys_process.c,v 1.147 2009/06/28 11:42:07 yamt Exp $ */ | 1 | /* $NetBSD: sys_process.c,v 1.148 2009/10/02 22:18:57 elad 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,49 +108,123 @@ | @@ -108,49 +108,123 @@ | |||
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_process.c,v 1.147 2009/06/28 11:42:07 yamt Exp $"); | 121 | __KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.148 2009/10/02 22:18:57 elad Exp $"); | |
122 | 122 | |||
123 | #include "opt_ptrace.h" | 123 | #include "opt_ptrace.h" | |
124 | #include "opt_ktrace.h" | 124 | #include "opt_ktrace.h" | |
125 | 125 | |||
126 | #include <sys/param.h> | 126 | #include <sys/param.h> | |
127 | #include <sys/systm.h> | 127 | #include <sys/systm.h> | |
128 | #include <sys/proc.h> | 128 | #include <sys/proc.h> | |
129 | #include <sys/errno.h> | 129 | #include <sys/errno.h> | |
130 | #include <sys/ptrace.h> | 130 | #include <sys/ptrace.h> | |
131 | #include <sys/uio.h> | 131 | #include <sys/uio.h> | |
132 | #include <sys/user.h> | 132 | #include <sys/user.h> | |
133 | #include <sys/ras.h> | 133 | #include <sys/ras.h> | |
134 | #include <sys/kmem.h> | 134 | #include <sys/kmem.h> | |
135 | #include <sys/kauth.h> | 135 | #include <sys/kauth.h> | |
136 | #include <sys/mount.h> | 136 | #include <sys/mount.h> | |
137 | #include <sys/syscallargs.h> | 137 | #include <sys/syscallargs.h> | |
138 | 138 | |||
139 | #include <uvm/uvm_extern.h> | 139 | #include <uvm/uvm_extern.h> | |
140 | 140 | |||
141 | #include <machine/reg.h> | 141 | #include <machine/reg.h> | |
142 | 142 | |||
143 | #ifdef PTRACE | 143 | #ifdef PTRACE | |
144 | static kauth_listener_t ptrace_listener; | |||
145 | ||||
146 | static int | |||
147 | ptrace_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie, | |||
148 | void *arg0, void *arg1, void *arg2, void *arg3) | |||
149 | { | |||
150 | struct proc *p; | |||
151 | int result; | |||
152 | ||||
153 | result = KAUTH_RESULT_DEFER; | |||
154 | p = arg0; | |||
155 | ||||
156 | if (action != KAUTH_PROCESS_PTRACE) | |||
157 | return result; | |||
158 | ||||
159 | switch ((u_long)arg1) { | |||
160 | case PT_TRACE_ME: | |||
161 | case PT_ATTACH: | |||
162 | case PT_WRITE_I: | |||
163 | case PT_WRITE_D: | |||
164 | case PT_READ_I: | |||
165 | case PT_READ_D: | |||
166 | case PT_IO: | |||
167 | #ifdef PT_GETREGS | |||
168 | case PT_GETREGS: | |||
169 | #endif | |||
170 | #ifdef PT_SETREGS | |||
171 | case PT_SETREGS: | |||
172 | #endif | |||
173 | #ifdef PT_GETFPREGS | |||
174 | case PT_GETFPREGS: | |||
175 | #endif | |||
176 | #ifdef PT_SETFPREGS | |||
177 | case PT_SETFPREGS: | |||
178 | #endif | |||
179 | #ifdef __HAVE_PTRACE_MACHDEP | |||
180 | PTRACE_MACHDEP_REQUEST_CASES | |||
181 | #endif | |||
182 | if (kauth_cred_getuid(cred) != kauth_cred_getuid(p->p_cred) || | |||
183 | ISSET(p->p_flag, PK_SUGID)) { | |||
184 | break; | |||
185 | } | |||
186 | ||||
187 | result = KAUTH_RESULT_ALLOW; | |||
188 | ||||
189 | break; | |||
190 | ||||
191 | #ifdef PT_STEP | |||
192 | case PT_STEP: | |||
193 | #endif | |||
194 | case PT_CONTINUE: | |||
195 | case PT_KILL: | |||
196 | case PT_DETACH: | |||
197 | case PT_LWPINFO: | |||
198 | case PT_SYSCALL: | |||
199 | case PT_DUMPCORE: | |||
200 | result = KAUTH_RESULT_ALLOW; | |||
201 | break; | |||
202 | ||||
203 | default: | |||
204 | break; | |||
205 | } | |||
206 | ||||
207 | return result; | |||
208 | } | |||
209 | ||||
210 | void | |||
211 | ptrace_init(void) | |||
212 | { | |||
213 | ||||
214 | ptrace_listener = kauth_listen_scope(KAUTH_SCOPE_PROCESS, | |||
215 | ptrace_listener_cb, NULL); | |||
216 | } | |||
217 | ||||
144 | /* | 218 | /* | |
145 | * Process debugging system call. | 219 | * Process debugging system call. | |
146 | */ | 220 | */ | |
147 | int | 221 | int | |
148 | sys_ptrace(struct lwp *l, const struct sys_ptrace_args *uap, register_t *retval) | 222 | sys_ptrace(struct lwp *l, const struct sys_ptrace_args *uap, register_t *retval) | |
149 | { | 223 | { | |
150 | /* { | 224 | /* { | |
151 | syscallarg(int) req; | 225 | syscallarg(int) req; | |
152 | syscallarg(pid_t) pid; | 226 | syscallarg(pid_t) pid; | |
153 | syscallarg(void *) addr; | 227 | syscallarg(void *) addr; | |
154 | syscallarg(int) data; | 228 | syscallarg(int) data; | |
155 | } */ | 229 | } */ | |
156 | struct proc *p = l->l_proc; | 230 | struct proc *p = l->l_proc; | |
@@ -948,13 +1022,14 @@ process_stoptrace(void) | @@ -948,13 +1022,14 @@ process_stoptrace(void) | |||
948 | mutex_exit(proc_lock); | 1022 | mutex_exit(proc_lock); | |
949 | 1023 | |||
950 | /* | 1024 | /* | |
951 | * Call issignal() once only, to have it take care of the | 1025 | * Call issignal() once only, to have it take care of the | |
952 | * pending stop. Signal processing will take place as usual | 1026 | * pending stop. Signal processing will take place as usual | |
953 | * from userret(). | 1027 | * from userret(). | |
954 | */ | 1028 | */ | |
955 | KERNEL_UNLOCK_ALL(l, &l->l_biglocks); | 1029 | KERNEL_UNLOCK_ALL(l, &l->l_biglocks); | |
956 | (void)issignal(l); | 1030 | (void)issignal(l); | |
957 | mutex_exit(p->p_lock); | 1031 | mutex_exit(p->p_lock); | |
958 | KERNEL_LOCK(l->l_biglocks, l); | 1032 | KERNEL_LOCK(l->l_biglocks, l); | |
959 | } | 1033 | } | |
960 | #endif /* KTRACE || PTRACE */ | 1034 | #endif /* KTRACE || PTRACE */ | |
1035 |
--- src/sys/secmodel/suser/secmodel_suser.c 2009/10/02 22:05:52 1.4
+++ src/sys/secmodel/suser/secmodel_suser.c 2009/10/02 22:18:57 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: secmodel_suser.c,v 1.4 2009/10/02 22:05:52 elad Exp $ */ | 1 | /* $NetBSD: secmodel_suser.c,v 1.5 2009/10/02 22:18:57 elad Exp $ */ | |
2 | /*- | 2 | /*- | |
3 | * Copyright (c) 2006 Elad Efrat <elad@NetBSD.org> | 3 | * Copyright (c) 2006 Elad Efrat <elad@NetBSD.org> | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * 3. The name of the author may not be used to endorse or promote products | 14 | * 3. The name of the author may not be used to endorse or promote products | |
@@ -28,27 +28,27 @@ | @@ -28,27 +28,27 @@ | |||
28 | 28 | |||
29 | /* | 29 | /* | |
30 | * This file contains kauth(9) listeners needed to implement the traditional | 30 | * This file contains kauth(9) listeners needed to implement the traditional | |
31 | * NetBSD superuser access restrictions. | 31 | * NetBSD superuser access restrictions. | |
32 | * | 32 | * | |
33 | * There are two main resources a request can be issued to: user-owned and | 33 | * There are two main resources a request can be issued to: user-owned and | |
34 | * system owned. For the first, traditional Unix access checks are done, as | 34 | * system owned. For the first, traditional Unix access checks are done, as | |
35 | * well as superuser checks. If needed, the request context is examined before | 35 | * well as superuser checks. If needed, the request context is examined before | |
36 | * a decision is made. For the latter, usually only superuser checks are done | 36 | * a decision is made. For the latter, usually only superuser checks are done | |
37 | * as normal users are not allowed to access system resources. | 37 | * as normal users are not allowed to access system resources. | |
38 | */ | 38 | */ | |
39 | 39 | |||
40 | #include <sys/cdefs.h> | 40 | #include <sys/cdefs.h> | |
41 | __KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.4 2009/10/02 22:05:52 elad Exp $"); | 41 | __KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.5 2009/10/02 22:18:57 elad Exp $"); | |
42 | 42 | |||
43 | #include <sys/types.h> | 43 | #include <sys/types.h> | |
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/kauth.h> | 45 | #include <sys/kauth.h> | |
46 | 46 | |||
47 | #include <sys/acct.h> | 47 | #include <sys/acct.h> | |
48 | #include <sys/mutex.h> | 48 | #include <sys/mutex.h> | |
49 | #include <sys/ktrace.h> | 49 | #include <sys/ktrace.h> | |
50 | #include <sys/mount.h> | 50 | #include <sys/mount.h> | |
51 | #include <sys/pset.h> | 51 | #include <sys/pset.h> | |
52 | #include <sys/socketvar.h> | 52 | #include <sys/socketvar.h> | |
53 | #include <sys/sysctl.h> | 53 | #include <sys/sysctl.h> | |
54 | #include <sys/tty.h> | 54 | #include <sys/tty.h> | |
@@ -630,83 +630,31 @@ secmodel_suser_process_cb(kauth_cred_t c | @@ -630,83 +630,31 @@ secmodel_suser_process_cb(kauth_cred_t c | |||
630 | kauth_cred_getuid(p->p_cred) || | 630 | kauth_cred_getuid(p->p_cred) || | |
631 | ISSET(p->p_flag, PK_SUGID)) { | 631 | ISSET(p->p_flag, PK_SUGID)) { | |
632 | break; | 632 | break; | |
633 | } | 633 | } | |
634 | /*FALLTHROUGH*/ | 634 | /*FALLTHROUGH*/ | |
635 | default: | 635 | default: | |
636 | result = KAUTH_RESULT_ALLOW; | 636 | result = KAUTH_RESULT_ALLOW; | |
637 | break; | 637 | break; | |
638 | } | 638 | } | |
639 | 639 | |||
640 | break; | 640 | break; | |
641 | } | 641 | } | |
642 | 642 | |||
643 | case KAUTH_PROCESS_PTRACE: { | 643 | case KAUTH_PROCESS_PTRACE: | |
644 | switch ((u_long)arg1) { | 644 | if (isroot) | |
645 | case PT_TRACE_ME: | |||
646 | case PT_ATTACH: | |||
647 | case PT_WRITE_I: | |||
648 | case PT_WRITE_D: | |||
649 | case PT_READ_I: | |||
650 | case PT_READ_D: | |||
651 | case PT_IO: | |||
652 | #ifdef PT_GETREGS | |||
653 | case PT_GETREGS: | |||
654 | #endif | |||
655 | #ifdef PT_SETREGS | |||
656 | case PT_SETREGS: | |||
657 | #endif | |||
658 | #ifdef PT_GETFPREGS | |||
659 | case PT_GETFPREGS: | |||
660 | #endif | |||
661 | #ifdef PT_SETFPREGS | |||
662 | case PT_SETFPREGS: | |||
663 | #endif | |||
664 | #ifdef __HAVE_PTRACE_MACHDEP | |||
665 | PTRACE_MACHDEP_REQUEST_CASES | |||
666 | #endif | |||
667 | if (isroot) { | |||
668 | result = KAUTH_RESULT_ALLOW; | |||
669 | break; | |||
670 | } | |||
671 | ||||
672 | if (kauth_cred_getuid(cred) != | |||
673 | kauth_cred_getuid(p->p_cred) || | |||
674 | ISSET(p->p_flag, PK_SUGID)) { | |||
675 | break; | |||
676 | } | |||
677 | ||||
678 | result = KAUTH_RESULT_ALLOW; | |||
679 | break; | |||
680 | ||||
681 | #ifdef PT_STEP | |||
682 | case PT_STEP: | |||
683 | #endif | |||
684 | case PT_CONTINUE: | |||
685 | case PT_KILL: | |||
686 | case PT_DETACH: | |||
687 | case PT_LWPINFO: | |||
688 | case PT_SYSCALL: | |||
689 | case PT_DUMPCORE: | |||
690 | result = KAUTH_RESULT_ALLOW; | 645 | result = KAUTH_RESULT_ALLOW; | |
691 | break; | |||
692 | ||||
693 | default: | |||
694 | result = KAUTH_RESULT_DEFER; | |||
695 | break; | |||
696 | } | |||
697 | 646 | |||
698 | break; | 647 | break; | |
699 | } | |||
700 | 648 | |||
701 | case KAUTH_PROCESS_CORENAME: | 649 | case KAUTH_PROCESS_CORENAME: | |
702 | if (isroot || proc_uidmatch(cred, p->p_cred) == 0) | 650 | if (isroot || proc_uidmatch(cred, p->p_cred) == 0) | |
703 | result = KAUTH_RESULT_ALLOW; | 651 | result = KAUTH_RESULT_ALLOW; | |
704 | 652 | |||
705 | break; | 653 | break; | |
706 | 654 | |||
707 | case KAUTH_PROCESS_FORK: { | 655 | case KAUTH_PROCESS_FORK: { | |
708 | int lnprocs = (int)(unsigned long)arg2; | 656 | int lnprocs = (int)(unsigned long)arg2; | |
709 | 657 | |||
710 | /* | 658 | /* | |
711 | * Don't allow a nonprivileged user to use the last few | 659 | * Don't allow a nonprivileged user to use the last few | |
712 | * processes. The variable lnprocs is the current number of | 660 | * processes. The variable lnprocs is the current number of |
--- src/sys/sys/ptrace.h 2008/01/05 12:41:43 1.40
+++ src/sys/sys/ptrace.h 2009/10/02 22:18:56 1.41
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ptrace.h,v 1.40 2008/01/05 12:41:43 dsl Exp $ */ | 1 | /* $NetBSD: ptrace.h,v 1.41 2009/10/02 22:18:56 elad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1984, 1993 | 4 | * Copyright (c) 1984, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -89,26 +89,28 @@ struct reg; | @@ -89,26 +89,28 @@ struct reg; | |||
89 | #define process_reg64 struct reg | 89 | #define process_reg64 struct reg | |
90 | #endif | 90 | #endif | |
91 | #endif | 91 | #endif | |
92 | #if defined(PT_GETFPREGS) || defined(PT_SETFPREGS) | 92 | #if defined(PT_GETFPREGS) || defined(PT_SETFPREGS) | |
93 | struct fpreg; | 93 | struct fpreg; | |
94 | #ifndef process_fpreg32 | 94 | #ifndef process_fpreg32 | |
95 | #define process_fpreg32 struct fpreg | 95 | #define process_fpreg32 struct fpreg | |
96 | #endif | 96 | #endif | |
97 | #ifndef process_fpreg64 | 97 | #ifndef process_fpreg64 | |
98 | #define process_fpreg64 struct fpreg | 98 | #define process_fpreg64 struct fpreg | |
99 | #endif | 99 | #endif | |
100 | #endif | 100 | #endif | |
101 | 101 | |||
102 | void ptrace_init(void); | |||
103 | ||||
102 | int process_doregs(struct lwp *, struct lwp *, struct uio *); | 104 | int process_doregs(struct lwp *, struct lwp *, struct uio *); | |
103 | int process_validregs(struct lwp *); | 105 | int process_validregs(struct lwp *); | |
104 | 106 | |||
105 | int process_dofpregs(struct lwp *, struct lwp *, struct uio *); | 107 | int process_dofpregs(struct lwp *, struct lwp *, struct uio *); | |
106 | int process_validfpregs(struct lwp *); | 108 | int process_validfpregs(struct lwp *); | |
107 | 109 | |||
108 | int process_domem(struct lwp *, struct lwp *, struct uio *); | 110 | int process_domem(struct lwp *, struct lwp *, struct uio *); | |
109 | 111 | |||
110 | void process_stoptrace(void); | 112 | void process_stoptrace(void); | |
111 | 113 | |||
112 | void proc_reparent(struct proc *, struct proc *); | 114 | void proc_reparent(struct proc *, struct proc *); | |
113 | #ifdef PT_GETFPREGS | 115 | #ifdef PT_GETFPREGS | |
114 | int process_read_fpregs(struct lwp *, struct fpreg *); | 116 | int process_read_fpregs(struct lwp *, struct fpreg *); |