2005-01-09 23:25:26 +03:00
|
|
|
/* $NetBSD: sys_process.c,v 1.94 2005/01/09 20:25:26 christos Exp $ */
|
1994-08-15 20:32:41 +04:00
|
|
|
|
1994-08-15 20:29:22 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1982, 1986, 1989, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
* (c) UNIX System Laboratories, Inc.
|
|
|
|
* All or some portions of this file are derived from material licensed
|
|
|
|
* to the University of California by American Telephone and Telegraph
|
|
|
|
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
|
|
|
* the permission of UNIX System Laboratories, Inc.
|
|
|
|
*
|
2002-05-09 19:44:44 +04:00
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Jan-Simon Pendry.
|
|
|
|
*
|
1994-08-15 20:29:22 +04:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* from: @(#)sys_process.c 8.1 (Berkeley) 6/10/93
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1993 Jan-Simon Pendry.
|
|
|
|
* Copyright (c) 1994 Christopher G. Demetriou. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Jan-Simon Pendry.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
1994-08-15 20:29:22 +04:00
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* from: @(#)sys_process.c 8.1 (Berkeley) 6/10/93
|
|
|
|
*/
|
|
|
|
|
1994-08-15 20:32:41 +04:00
|
|
|
/*
|
|
|
|
* References:
|
|
|
|
* (1) Bach's "The Design of the UNIX Operating System",
|
|
|
|
* (2) sys/miscfs/procfs from UCB's 4.4BSD-Lite distribution,
|
|
|
|
* (3) the "4.4BSD Programmer's Reference Manual" published
|
|
|
|
* by USENIX and O'Reilly & Associates.
|
|
|
|
* The 4.4BSD PRM does a reasonably good job of documenting what the various
|
|
|
|
* ptrace() requests should actually do, and its text is quoted several times
|
|
|
|
* in this file.
|
|
|
|
*/
|
|
|
|
|
2001-11-12 18:25:01 +03:00
|
|
|
#include <sys/cdefs.h>
|
2005-01-09 23:25:26 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.94 2005/01/09 20:25:26 christos Exp $");
|
2001-11-12 18:25:01 +03:00
|
|
|
|
1994-08-15 20:29:22 +04:00
|
|
|
#include <sys/param.h>
|
1994-10-20 07:22:35 +03:00
|
|
|
#include <sys/systm.h>
|
1994-08-15 20:29:22 +04:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/errno.h>
|
1994-08-15 20:32:41 +04:00
|
|
|
#include <sys/ptrace.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/user.h>
|
2002-08-28 11:27:14 +04:00
|
|
|
#include <sys/ras.h>
|
2005-01-09 22:22:55 +03:00
|
|
|
#include <sys/malloc.h>
|
1994-08-15 20:32:41 +04:00
|
|
|
|
1994-10-20 07:22:35 +03:00
|
|
|
#include <sys/mount.h>
|
2003-01-18 13:06:22 +03:00
|
|
|
#include <sys/sa.h>
|
1994-10-20 07:22:35 +03:00
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
|
1998-02-05 10:59:28 +03:00
|
|
|
#include <uvm/uvm_extern.h>
|
|
|
|
|
1994-08-15 20:32:41 +04:00
|
|
|
#include <machine/reg.h>
|
|
|
|
|
|
|
|
/* Macros to clear/set/test flags. */
|
|
|
|
#define SET(t, f) (t) |= (f)
|
|
|
|
#define CLR(t, f) (t) &= ~(f)
|
|
|
|
#define ISSET(t, f) ((t) & (f))
|
1994-08-15 20:29:22 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Process debugging system call.
|
|
|
|
*/
|
1994-10-20 07:22:35 +03:00
|
|
|
int
|
2003-01-18 13:06:22 +03:00
|
|
|
sys_ptrace(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-09-20 01:40:36 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_ptrace_args /* {
|
1994-10-20 07:22:35 +03:00
|
|
|
syscallarg(int) req;
|
|
|
|
syscallarg(pid_t) pid;
|
|
|
|
syscallarg(caddr_t) addr;
|
|
|
|
syscallarg(int) data;
|
1995-09-20 01:40:36 +04:00
|
|
|
} */ *uap = v;
|
2003-01-18 13:06:22 +03:00
|
|
|
struct proc *p = l->l_proc;
|
2003-02-08 00:44:45 +03:00
|
|
|
struct lwp *lt, *lr;
|
1994-08-15 20:32:41 +04:00
|
|
|
struct proc *t; /* target process */
|
|
|
|
struct uio uio;
|
|
|
|
struct iovec iov;
|
2002-03-17 20:02:45 +03:00
|
|
|
struct ptrace_io_desc piod;
|
2003-05-20 22:16:08 +04:00
|
|
|
struct ptrace_lwpinfo pl;
|
|
|
|
int s, error, write, tmp, size;
|
2005-01-09 22:22:55 +03:00
|
|
|
char *path;
|
1994-08-15 20:32:41 +04:00
|
|
|
|
|
|
|
/* "A foolish consistency..." XXX */
|
1994-10-20 07:22:35 +03:00
|
|
|
if (SCARG(uap, req) == PT_TRACE_ME)
|
1994-08-15 20:32:41 +04:00
|
|
|
t = p;
|
|
|
|
else {
|
1996-05-15 10:17:47 +04:00
|
|
|
|
1994-08-15 20:32:41 +04:00
|
|
|
/* Find the process we're supposed to be operating on. */
|
1994-10-20 07:22:35 +03:00
|
|
|
if ((t = pfind(SCARG(uap, pid))) == NULL)
|
1994-08-15 20:32:41 +04:00
|
|
|
return (ESRCH);
|
|
|
|
}
|
|
|
|
|
2002-01-12 00:16:27 +03:00
|
|
|
/* Can't trace a process that's currently exec'ing. */
|
|
|
|
if ((t->p_flag & P_INEXEC) != 0)
|
|
|
|
return EAGAIN;
|
|
|
|
|
1994-08-15 20:32:41 +04:00
|
|
|
/* Make sure we can operate on it. */
|
1994-10-20 07:22:35 +03:00
|
|
|
switch (SCARG(uap, req)) {
|
1994-08-15 20:32:41 +04:00
|
|
|
case PT_TRACE_ME:
|
|
|
|
/* Saying that you're being traced is always legal. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PT_ATTACH:
|
2003-01-23 20:35:18 +03:00
|
|
|
case PT_DUMPCORE:
|
1994-08-15 20:32:41 +04:00
|
|
|
/*
|
|
|
|
* You can't attach to a process if:
|
|
|
|
* (1) it's the process that's doing the attaching,
|
|
|
|
*/
|
|
|
|
if (t->p_pid == p->p_pid)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
/*
|
2000-09-24 11:31:28 +04:00
|
|
|
* (2) it's a system process
|
|
|
|
*/
|
|
|
|
if (t->p_flag & P_SYSTEM)
|
|
|
|
return (EPERM);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* (3) it's already being traced, or
|
1994-08-15 20:32:41 +04:00
|
|
|
*/
|
1994-09-24 11:17:18 +04:00
|
|
|
if (ISSET(t->p_flag, P_TRACED))
|
1994-08-15 20:32:41 +04:00
|
|
|
return (EBUSY);
|
|
|
|
|
|
|
|
/*
|
2000-09-24 11:31:28 +04:00
|
|
|
* (4) it's not owned by you, or is set-id on exec
|
1996-05-15 10:17:47 +04:00
|
|
|
* (unless you're root), or...
|
1994-08-15 20:32:41 +04:00
|
|
|
*/
|
|
|
|
if ((t->p_cred->p_ruid != p->p_cred->p_ruid ||
|
|
|
|
ISSET(t->p_flag, P_SUGID)) &&
|
|
|
|
(error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
|
|
|
return (error);
|
1996-05-15 10:17:47 +04:00
|
|
|
|
|
|
|
/*
|
2000-09-24 11:31:28 +04:00
|
|
|
* (5) ...it's init, which controls the security level
|
1996-05-15 10:17:47 +04:00
|
|
|
* of the entire system, and the system was not
|
2000-09-24 11:31:28 +04:00
|
|
|
* compiled with permanently insecure mode turned on
|
1996-05-15 10:17:47 +04:00
|
|
|
*/
|
1997-04-28 06:29:52 +04:00
|
|
|
if (t == initproc && securelevel > -1)
|
1996-05-15 10:17:47 +04:00
|
|
|
return (EPERM);
|
1999-03-25 07:45:56 +03:00
|
|
|
|
|
|
|
/*
|
2000-09-24 11:31:28 +04:00
|
|
|
* (6) the tracer is chrooted, and its root directory is
|
1999-03-25 07:45:56 +03:00
|
|
|
* not at or above the root directory of the tracee
|
|
|
|
*/
|
|
|
|
|
2003-06-30 02:28:00 +04:00
|
|
|
if (!proc_isunder(t, p))
|
1999-03-25 07:45:56 +03:00
|
|
|
return EPERM;
|
1994-08-15 20:32:41 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PT_READ_I:
|
|
|
|
case PT_READ_D:
|
|
|
|
case PT_WRITE_I:
|
|
|
|
case PT_WRITE_D:
|
|
|
|
case PT_CONTINUE:
|
2002-03-17 20:02:45 +03:00
|
|
|
case PT_IO:
|
1994-08-15 20:32:41 +04:00
|
|
|
case PT_KILL:
|
|
|
|
case PT_DETACH:
|
2003-05-20 22:16:08 +04:00
|
|
|
case PT_LWPINFO:
|
1994-08-15 20:32:41 +04:00
|
|
|
#ifdef PT_STEP
|
|
|
|
case PT_STEP:
|
|
|
|
#endif
|
|
|
|
#ifdef PT_GETREGS
|
|
|
|
case PT_GETREGS:
|
|
|
|
#endif
|
|
|
|
#ifdef PT_SETREGS
|
|
|
|
case PT_SETREGS:
|
|
|
|
#endif
|
|
|
|
#ifdef PT_GETFPREGS
|
|
|
|
case PT_GETFPREGS:
|
|
|
|
#endif
|
|
|
|
#ifdef PT_SETFPREGS
|
|
|
|
case PT_SETFPREGS:
|
|
|
|
#endif
|
2001-12-05 03:58:05 +03:00
|
|
|
|
|
|
|
#ifdef __HAVE_PTRACE_MACHDEP
|
|
|
|
PTRACE_MACHDEP_REQUEST_CASES
|
|
|
|
#endif
|
|
|
|
|
1994-08-15 20:32:41 +04:00
|
|
|
/*
|
|
|
|
* You can't do what you want to the process if:
|
|
|
|
* (1) It's not being traced at all,
|
|
|
|
*/
|
|
|
|
if (!ISSET(t->p_flag, P_TRACED))
|
|
|
|
return (EPERM);
|
|
|
|
|
|
|
|
/*
|
1997-04-28 08:49:27 +04:00
|
|
|
* (2) it's being traced by procfs (which has
|
|
|
|
* different signal delivery semantics),
|
|
|
|
*/
|
|
|
|
if (ISSET(t->p_flag, P_FSTRACE))
|
|
|
|
return (EBUSY);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* (3) it's not being traced by _you_, or
|
1994-08-15 20:32:41 +04:00
|
|
|
*/
|
|
|
|
if (t->p_pptr != p)
|
|
|
|
return (EBUSY);
|
|
|
|
|
|
|
|
/*
|
1997-04-28 08:49:27 +04:00
|
|
|
* (4) it's not currently stopped.
|
1994-08-15 20:32:41 +04:00
|
|
|
*/
|
|
|
|
if (t->p_stat != SSTOP || !ISSET(t->p_flag, P_WAITED))
|
|
|
|
return (EBUSY);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* It was not a legal request. */
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do single-step fixup if needed. */
|
|
|
|
FIX_SSTEP(t);
|
|
|
|
|
2003-01-18 13:06:22 +03:00
|
|
|
/*
|
|
|
|
* XXX NJWLWP
|
|
|
|
*
|
|
|
|
* The entire ptrace interface needs work to be useful to a
|
|
|
|
* process with multiple LWPs. For the moment, we'll kluge
|
|
|
|
* this; memory access will be fine, but register access will
|
|
|
|
* be weird.
|
|
|
|
*/
|
|
|
|
|
|
|
|
lt = proc_representative_lwp(t);
|
|
|
|
|
1994-08-15 20:32:41 +04:00
|
|
|
/* Now do the operation. */
|
1995-02-09 08:19:18 +03:00
|
|
|
write = 0;
|
1994-08-15 20:32:41 +04:00
|
|
|
*retval = 0;
|
2000-07-28 08:21:26 +04:00
|
|
|
tmp = 0;
|
1994-08-15 20:32:41 +04:00
|
|
|
|
1994-10-20 07:22:35 +03:00
|
|
|
switch (SCARG(uap, req)) {
|
1994-08-15 20:32:41 +04:00
|
|
|
case PT_TRACE_ME:
|
|
|
|
/* Just set the trace flag. */
|
|
|
|
SET(t->p_flag, P_TRACED);
|
2002-07-26 00:04:02 +04:00
|
|
|
t->p_opptr = t->p_pptr;
|
1994-08-15 20:32:41 +04:00
|
|
|
return (0);
|
|
|
|
|
2001-07-22 17:33:58 +04:00
|
|
|
case PT_WRITE_I: /* XXX no separate I and D spaces */
|
1994-08-15 20:32:41 +04:00
|
|
|
case PT_WRITE_D:
|
2002-08-28 11:27:14 +04:00
|
|
|
#if defined(__HAVE_RAS)
|
|
|
|
/*
|
|
|
|
* Can't write to a RAS
|
|
|
|
*/
|
2003-11-04 13:33:15 +03:00
|
|
|
if (!LIST_EMPTY(&t->p_raslist) &&
|
2002-08-28 11:27:14 +04:00
|
|
|
(ras_lookup(t, SCARG(uap, addr)) != (caddr_t)-1)) {
|
|
|
|
return (EACCES);
|
|
|
|
}
|
|
|
|
#endif
|
1994-08-15 20:32:41 +04:00
|
|
|
write = 1;
|
2000-07-28 08:21:26 +04:00
|
|
|
tmp = SCARG(uap, data);
|
2001-07-22 17:33:58 +04:00
|
|
|
case PT_READ_I: /* XXX no separate I and D spaces */
|
1994-08-15 20:32:41 +04:00
|
|
|
case PT_READ_D:
|
|
|
|
/* write = 0 done above. */
|
2000-07-28 08:21:26 +04:00
|
|
|
iov.iov_base = (caddr_t)&tmp;
|
|
|
|
iov.iov_len = sizeof(tmp);
|
1994-08-15 20:32:41 +04:00
|
|
|
uio.uio_iov = &iov;
|
|
|
|
uio.uio_iovcnt = 1;
|
2004-05-26 20:28:05 +04:00
|
|
|
uio.uio_offset = (off_t)(unsigned long)SCARG(uap, addr);
|
2000-07-28 08:21:26 +04:00
|
|
|
uio.uio_resid = sizeof(tmp);
|
1994-08-15 20:32:41 +04:00
|
|
|
uio.uio_segflg = UIO_SYSSPACE;
|
|
|
|
uio.uio_rw = write ? UIO_WRITE : UIO_READ;
|
2004-09-17 18:11:20 +04:00
|
|
|
uio.uio_procp = NULL;
|
2003-06-30 02:28:00 +04:00
|
|
|
error = process_domem(p, t, &uio);
|
2000-07-28 08:21:26 +04:00
|
|
|
if (!write)
|
|
|
|
*retval = tmp;
|
|
|
|
return (error);
|
2002-03-17 20:02:45 +03:00
|
|
|
|
|
|
|
case PT_IO:
|
|
|
|
error = copyin(SCARG(uap, addr), &piod, sizeof(piod));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
iov.iov_base = piod.piod_addr;
|
|
|
|
iov.iov_len = piod.piod_len;
|
|
|
|
uio.uio_iov = &iov;
|
|
|
|
uio.uio_iovcnt = 1;
|
2004-05-26 20:28:05 +04:00
|
|
|
uio.uio_offset = (off_t)(unsigned long)piod.piod_offs;
|
2002-03-17 20:02:45 +03:00
|
|
|
uio.uio_resid = piod.piod_len;
|
|
|
|
uio.uio_segflg = UIO_USERSPACE;
|
2003-06-30 02:28:00 +04:00
|
|
|
uio.uio_procp = p;
|
2002-03-17 20:02:45 +03:00
|
|
|
switch (piod.piod_op) {
|
|
|
|
case PIOD_READ_D:
|
|
|
|
case PIOD_READ_I:
|
|
|
|
uio.uio_rw = UIO_READ;
|
|
|
|
break;
|
|
|
|
case PIOD_WRITE_D:
|
|
|
|
case PIOD_WRITE_I:
|
|
|
|
uio.uio_rw = UIO_WRITE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
2003-06-30 02:28:00 +04:00
|
|
|
error = process_domem(p, t, &uio);
|
2002-03-17 20:02:45 +03:00
|
|
|
piod.piod_len -= uio.uio_resid;
|
|
|
|
(void) copyout(&piod, SCARG(uap, addr), sizeof(piod));
|
|
|
|
return (error);
|
1994-08-15 20:32:41 +04:00
|
|
|
|
2003-01-23 20:35:18 +03:00
|
|
|
case PT_DUMPCORE:
|
2005-01-09 22:22:55 +03:00
|
|
|
if ((path = SCARG(uap, addr)) != NULL) {
|
|
|
|
char *dst;
|
|
|
|
int len = SCARG(uap, data);
|
|
|
|
if (len >= MAXPATHLEN)
|
|
|
|
return EINVAL;
|
|
|
|
dst = malloc(len + 1, M_TEMP, M_WAITOK);
|
|
|
|
if ((error = copyin(path, dst, len)) != 0) {
|
|
|
|
free(dst, M_TEMP);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
path = dst;
|
2005-01-09 23:25:26 +03:00
|
|
|
path[len] = '\0';
|
2005-01-09 22:22:55 +03:00
|
|
|
}
|
|
|
|
error = coredump(lt, path);
|
|
|
|
if (path)
|
|
|
|
free(path, M_TEMP);
|
|
|
|
return error;
|
2003-01-23 20:35:18 +03:00
|
|
|
|
1994-08-15 20:32:41 +04:00
|
|
|
#ifdef PT_STEP
|
|
|
|
case PT_STEP:
|
|
|
|
/*
|
|
|
|
* From the 4.4BSD PRM:
|
|
|
|
* "Execution continues as in request PT_CONTINUE; however
|
|
|
|
* as soon as possible after execution of at least one
|
|
|
|
* instruction, execution stops again. [ ... ]"
|
|
|
|
*/
|
|
|
|
#endif
|
|
|
|
case PT_CONTINUE:
|
1995-02-03 14:35:57 +03:00
|
|
|
case PT_DETACH:
|
1994-08-15 20:32:41 +04:00
|
|
|
/*
|
|
|
|
* From the 4.4BSD PRM:
|
|
|
|
* "The data argument is taken as a signal number and the
|
|
|
|
* child's execution continues at location addr as if it
|
1995-02-09 02:38:29 +03:00
|
|
|
* incurred that signal. Normally the signal number will
|
1994-08-15 20:32:41 +04:00
|
|
|
* be either 0 to indicate that the signal that caused the
|
|
|
|
* stop should be ignored, or that value fetched out of
|
|
|
|
* the process's image indicating which signal caused
|
|
|
|
* the stop. If addr is (int *)1 then execution continues
|
|
|
|
* from where it stopped."
|
|
|
|
*/
|
|
|
|
|
1994-10-20 07:22:35 +03:00
|
|
|
/* Check that the data is a valid signal number or zero. */
|
|
|
|
if (SCARG(uap, data) < 0 || SCARG(uap, data) >= NSIG)
|
1994-08-15 20:32:41 +04:00
|
|
|
return (EINVAL);
|
|
|
|
|
2003-01-18 13:06:22 +03:00
|
|
|
PHOLD(lt);
|
1995-08-13 13:05:51 +04:00
|
|
|
|
2002-08-28 11:27:14 +04:00
|
|
|
/* If the address parameter is not (int *)1, set the pc. */
|
|
|
|
if ((int *)SCARG(uap, addr) != (int *)1)
|
2003-01-18 13:06:22 +03:00
|
|
|
if ((error = process_set_pc(lt, SCARG(uap, addr))) != 0)
|
2002-08-28 11:27:14 +04:00
|
|
|
goto relebad;
|
|
|
|
|
1995-02-09 08:19:18 +03:00
|
|
|
#ifdef PT_STEP
|
1994-08-15 20:32:41 +04:00
|
|
|
/*
|
|
|
|
* Arrange for a single-step, if that's requested and possible.
|
|
|
|
*/
|
2003-01-18 13:06:22 +03:00
|
|
|
error = process_sstep(lt, SCARG(uap, req) == PT_STEP);
|
1996-02-04 05:15:01 +03:00
|
|
|
if (error)
|
1995-08-13 13:05:51 +04:00
|
|
|
goto relebad;
|
1995-02-09 08:19:18 +03:00
|
|
|
#endif
|
1994-08-15 20:32:41 +04:00
|
|
|
|
2003-01-18 13:06:22 +03:00
|
|
|
PRELE(lt);
|
1994-08-15 20:32:41 +04:00
|
|
|
|
1995-02-03 14:35:57 +03:00
|
|
|
if (SCARG(uap, req) == PT_DETACH) {
|
|
|
|
/* give process back to original parent or init */
|
2004-05-05 01:58:47 +04:00
|
|
|
s = proclist_lock_write();
|
2002-07-26 00:04:02 +04:00
|
|
|
if (t->p_opptr != t->p_pptr) {
|
|
|
|
struct proc *pp = t->p_opptr;
|
1995-02-03 14:35:57 +03:00
|
|
|
proc_reparent(t, pp ? pp : initproc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not being traced any more */
|
2002-07-26 00:04:02 +04:00
|
|
|
t->p_opptr = NULL;
|
2004-05-05 01:58:47 +04:00
|
|
|
proclist_unlock_write(s);
|
1995-02-03 14:35:57 +03:00
|
|
|
CLR(t->p_flag, P_TRACED|P_WAITED);
|
|
|
|
}
|
|
|
|
|
1995-06-09 03:51:01 +04:00
|
|
|
sendsig:
|
1994-08-15 20:32:41 +04:00
|
|
|
/* Finally, deliver the requested signal (or none). */
|
1995-02-03 14:35:57 +03:00
|
|
|
if (t->p_stat == SSTOP) {
|
|
|
|
t->p_xstat = SCARG(uap, data);
|
2000-08-21 01:50:06 +04:00
|
|
|
SCHED_LOCK(s);
|
2003-02-08 00:44:45 +03:00
|
|
|
lr = proc_unstop(t);
|
|
|
|
/*
|
|
|
|
* If the target needs to take a signal, there
|
|
|
|
* is no running LWP that will see it, and
|
|
|
|
* there is a LWP sleeping interruptably, then
|
|
|
|
* get it moving.
|
|
|
|
*/
|
|
|
|
if (lr && (t->p_xstat != 0))
|
|
|
|
setrunnable(lr);
|
2000-08-21 01:50:06 +04:00
|
|
|
SCHED_UNLOCK(s);
|
1995-02-03 14:35:57 +03:00
|
|
|
} else {
|
|
|
|
if (SCARG(uap, data) != 0)
|
|
|
|
psignal(t, SCARG(uap, data));
|
|
|
|
}
|
1994-08-15 20:32:41 +04:00
|
|
|
return (0);
|
|
|
|
|
1995-08-13 13:05:51 +04:00
|
|
|
relebad:
|
2003-01-18 13:06:22 +03:00
|
|
|
PRELE(lt);
|
1995-08-13 13:05:51 +04:00
|
|
|
return (error);
|
|
|
|
|
1994-08-15 20:32:41 +04:00
|
|
|
case PT_KILL:
|
|
|
|
/* just send the process a KILL signal. */
|
1994-10-20 07:22:35 +03:00
|
|
|
SCARG(uap, data) = SIGKILL;
|
1994-08-15 20:32:41 +04:00
|
|
|
goto sendsig; /* in PT_CONTINUE, above. */
|
|
|
|
|
|
|
|
case PT_ATTACH:
|
|
|
|
/*
|
|
|
|
* Go ahead and set the trace flag.
|
|
|
|
* Save the old parent (it's reset in
|
|
|
|
* _DETACH, and also in kern_exit.c:wait4()
|
|
|
|
* Reparent the process so that the tracing
|
|
|
|
* proc gets to see all the action.
|
|
|
|
* Stop the target.
|
|
|
|
*/
|
|
|
|
SET(t->p_flag, P_TRACED);
|
2004-05-05 01:58:47 +04:00
|
|
|
s = proclist_lock_write();
|
2002-07-26 00:04:02 +04:00
|
|
|
t->p_opptr = t->p_pptr;
|
|
|
|
if (t->p_pptr != p) {
|
|
|
|
t->p_pptr->p_flag |= P_CHTRACED;
|
1994-08-15 20:32:41 +04:00
|
|
|
proc_reparent(t, p);
|
2002-07-26 00:04:02 +04:00
|
|
|
}
|
2004-05-05 01:58:47 +04:00
|
|
|
proclist_unlock_write(s);
|
1995-06-06 00:57:54 +04:00
|
|
|
SCARG(uap, data) = SIGSTOP;
|
|
|
|
goto sendsig;
|
1994-08-15 20:32:41 +04:00
|
|
|
|
2003-05-20 22:16:08 +04:00
|
|
|
case PT_LWPINFO:
|
|
|
|
size = SCARG(uap, data);
|
|
|
|
if (size < sizeof(lwpid_t))
|
|
|
|
return (EINVAL);
|
|
|
|
error = copyin(SCARG(uap, addr), &pl, sizeof(lwpid_t));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
tmp = pl.pl_lwpid;
|
|
|
|
if (tmp == 0)
|
|
|
|
lt = LIST_FIRST(&t->p_lwps);
|
|
|
|
else {
|
|
|
|
LIST_FOREACH(lt, &t->p_lwps, l_sibling)
|
|
|
|
if (lt->l_lid == tmp)
|
|
|
|
break;
|
|
|
|
if (lt == NULL)
|
|
|
|
return (ESRCH);
|
|
|
|
lt = LIST_NEXT(lt, l_sibling);
|
|
|
|
}
|
|
|
|
pl.pl_lwpid = 0;
|
|
|
|
pl.pl_event = 0;
|
|
|
|
if (lt) {
|
|
|
|
pl.pl_lwpid = lt->l_lid;
|
|
|
|
if (lt->l_lid == t->p_sigctx.ps_lwp)
|
|
|
|
pl.pl_event = PL_EVENT_SIGNAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = copyout(&pl, SCARG(uap, addr), SCARG(uap, data));
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
1994-08-15 20:32:41 +04:00
|
|
|
#ifdef PT_SETREGS
|
|
|
|
case PT_SETREGS:
|
|
|
|
write = 1;
|
|
|
|
#endif
|
|
|
|
#ifdef PT_GETREGS
|
|
|
|
case PT_GETREGS:
|
|
|
|
/* write = 0 done above. */
|
|
|
|
#endif
|
|
|
|
#if defined(PT_SETREGS) || defined(PT_GETREGS)
|
2003-01-18 13:06:22 +03:00
|
|
|
tmp = SCARG(uap, data);
|
|
|
|
if (tmp != 0 && t->p_nlwps > 1) {
|
|
|
|
LIST_FOREACH(lt, &t->p_lwps, l_sibling)
|
|
|
|
if (lt->l_lid == tmp)
|
|
|
|
break;
|
|
|
|
if (lt == NULL)
|
|
|
|
return (ESRCH);
|
|
|
|
}
|
2003-06-30 02:28:00 +04:00
|
|
|
if (!process_validregs(t))
|
1994-08-15 20:32:41 +04:00
|
|
|
return (EINVAL);
|
|
|
|
else {
|
1994-10-20 07:22:35 +03:00
|
|
|
iov.iov_base = SCARG(uap, addr);
|
1994-08-15 20:32:41 +04:00
|
|
|
iov.iov_len = sizeof(struct reg);
|
|
|
|
uio.uio_iov = &iov;
|
|
|
|
uio.uio_iovcnt = 1;
|
|
|
|
uio.uio_offset = 0;
|
|
|
|
uio.uio_resid = sizeof(struct reg);
|
|
|
|
uio.uio_segflg = UIO_USERSPACE;
|
|
|
|
uio.uio_rw = write ? UIO_WRITE : UIO_READ;
|
2003-06-30 02:28:00 +04:00
|
|
|
uio.uio_procp = p;
|
|
|
|
return (process_doregs(p, lt, &uio));
|
1994-08-15 20:32:41 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PT_SETFPREGS
|
|
|
|
case PT_SETFPREGS:
|
|
|
|
write = 1;
|
|
|
|
#endif
|
|
|
|
#ifdef PT_GETFPREGS
|
|
|
|
case PT_GETFPREGS:
|
|
|
|
/* write = 0 done above. */
|
|
|
|
#endif
|
|
|
|
#if defined(PT_SETFPREGS) || defined(PT_GETFPREGS)
|
2003-01-18 13:06:22 +03:00
|
|
|
tmp = SCARG(uap, data);
|
|
|
|
if (tmp != 0 && t->p_nlwps > 1) {
|
|
|
|
LIST_FOREACH(lt, &t->p_lwps, l_sibling)
|
|
|
|
if (lt->l_lid == tmp)
|
|
|
|
break;
|
|
|
|
if (lt == NULL)
|
|
|
|
return (ESRCH);
|
|
|
|
}
|
2003-06-30 02:28:00 +04:00
|
|
|
if (!process_validfpregs(t))
|
1994-08-15 20:32:41 +04:00
|
|
|
return (EINVAL);
|
|
|
|
else {
|
1994-10-20 07:22:35 +03:00
|
|
|
iov.iov_base = SCARG(uap, addr);
|
1994-08-15 20:32:41 +04:00
|
|
|
iov.iov_len = sizeof(struct fpreg);
|
|
|
|
uio.uio_iov = &iov;
|
|
|
|
uio.uio_iovcnt = 1;
|
|
|
|
uio.uio_offset = 0;
|
|
|
|
uio.uio_resid = sizeof(struct fpreg);
|
|
|
|
uio.uio_segflg = UIO_USERSPACE;
|
|
|
|
uio.uio_rw = write ? UIO_WRITE : UIO_READ;
|
2003-06-30 02:28:00 +04:00
|
|
|
uio.uio_procp = p;
|
|
|
|
return (process_dofpregs(p, lt, &uio));
|
1994-08-15 20:32:41 +04:00
|
|
|
}
|
|
|
|
#endif
|
2001-12-05 03:58:05 +03:00
|
|
|
|
|
|
|
#ifdef __HAVE_PTRACE_MACHDEP
|
|
|
|
PTRACE_MACHDEP_REQUEST_CASES
|
2003-06-30 02:28:00 +04:00
|
|
|
return (ptrace_machdep_dorequest(p, lt,
|
2001-12-05 03:58:05 +03:00
|
|
|
SCARG(uap, req), SCARG(uap, addr),
|
|
|
|
SCARG(uap, data)));
|
|
|
|
#endif
|
1994-08-15 20:32:41 +04:00
|
|
|
}
|
1994-08-15 20:29:22 +04:00
|
|
|
|
1994-08-15 20:32:41 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
panic("ptrace: impossible");
|
|
|
|
#endif
|
1996-02-04 05:15:01 +03:00
|
|
|
return 0;
|
1994-08-15 20:29:22 +04:00
|
|
|
}
|
2002-05-09 19:44:44 +04:00
|
|
|
|
|
|
|
int
|
2003-06-30 02:28:00 +04:00
|
|
|
process_doregs(curp, l, uio)
|
|
|
|
struct proc *curp; /* tracer */
|
2003-01-18 13:06:22 +03:00
|
|
|
struct lwp *l; /* traced */
|
2002-05-09 19:44:44 +04:00
|
|
|
struct uio *uio;
|
|
|
|
{
|
|
|
|
#if defined(PT_GETREGS) || defined(PT_SETREGS)
|
|
|
|
int error;
|
|
|
|
struct reg r;
|
|
|
|
char *kv;
|
|
|
|
int kl;
|
|
|
|
|
2004-05-14 20:36:33 +04:00
|
|
|
if (uio->uio_offset < 0 || uio->uio_offset > (off_t)sizeof(r))
|
|
|
|
return EINVAL;
|
|
|
|
|
2003-06-30 02:28:00 +04:00
|
|
|
if ((error = process_checkioperm(curp, l->l_proc)) != 0)
|
2002-05-09 19:44:44 +04:00
|
|
|
return error;
|
|
|
|
|
|
|
|
kl = sizeof(r);
|
2004-05-14 20:36:33 +04:00
|
|
|
kv = (char *)&r;
|
2002-05-09 19:44:44 +04:00
|
|
|
|
|
|
|
kv += uio->uio_offset;
|
|
|
|
kl -= uio->uio_offset;
|
2004-05-14 20:36:33 +04:00
|
|
|
if ((size_t)kl > uio->uio_resid)
|
2002-05-09 19:44:44 +04:00
|
|
|
kl = uio->uio_resid;
|
|
|
|
|
2003-01-18 13:06:22 +03:00
|
|
|
PHOLD(l);
|
2002-05-09 19:44:44 +04:00
|
|
|
|
2003-01-18 13:06:22 +03:00
|
|
|
error = process_read_regs(l, &r);
|
2002-05-09 19:44:44 +04:00
|
|
|
if (error == 0)
|
|
|
|
error = uiomove(kv, kl, uio);
|
|
|
|
if (error == 0 && uio->uio_rw == UIO_WRITE) {
|
2003-01-18 13:06:22 +03:00
|
|
|
if (l->l_stat != LSSTOP)
|
2002-05-09 19:44:44 +04:00
|
|
|
error = EBUSY;
|
|
|
|
else
|
2003-01-18 13:06:22 +03:00
|
|
|
error = process_write_regs(l, &r);
|
2002-05-09 19:44:44 +04:00
|
|
|
}
|
|
|
|
|
2003-01-18 13:06:22 +03:00
|
|
|
PRELE(l);
|
2002-05-09 19:44:44 +04:00
|
|
|
|
|
|
|
uio->uio_offset = 0;
|
|
|
|
return (error);
|
|
|
|
#else
|
|
|
|
return (EINVAL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-06-30 02:28:00 +04:00
|
|
|
process_validregs(p)
|
|
|
|
struct proc *p;
|
2002-05-09 19:44:44 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
#if defined(PT_SETREGS) || defined(PT_GETREGS)
|
2003-06-30 02:28:00 +04:00
|
|
|
return ((p->p_flag & P_SYSTEM) == 0);
|
2002-05-09 19:44:44 +04:00
|
|
|
#else
|
|
|
|
return (0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-06-30 02:28:00 +04:00
|
|
|
process_dofpregs(curp, l, uio)
|
|
|
|
struct proc *curp; /* tracer */
|
2003-01-18 13:06:22 +03:00
|
|
|
struct lwp *l; /* traced */
|
2002-05-09 19:44:44 +04:00
|
|
|
struct uio *uio;
|
|
|
|
{
|
|
|
|
#if defined(PT_GETFPREGS) || defined(PT_SETFPREGS)
|
|
|
|
int error;
|
|
|
|
struct fpreg r;
|
|
|
|
char *kv;
|
|
|
|
int kl;
|
|
|
|
|
2004-05-14 20:36:33 +04:00
|
|
|
if (uio->uio_offset < 0 || uio->uio_offset > (off_t)sizeof(r))
|
|
|
|
return EINVAL;
|
|
|
|
|
2003-06-30 02:28:00 +04:00
|
|
|
if ((error = process_checkioperm(curp, l->l_proc)) != 0)
|
2002-05-09 19:44:44 +04:00
|
|
|
return (error);
|
|
|
|
|
|
|
|
kl = sizeof(r);
|
2004-05-14 20:36:33 +04:00
|
|
|
kv = (char *)&r;
|
2002-05-09 19:44:44 +04:00
|
|
|
|
|
|
|
kv += uio->uio_offset;
|
|
|
|
kl -= uio->uio_offset;
|
2004-05-14 20:36:33 +04:00
|
|
|
if ((size_t)kl > uio->uio_resid)
|
2002-05-09 19:44:44 +04:00
|
|
|
kl = uio->uio_resid;
|
|
|
|
|
2003-01-18 13:06:22 +03:00
|
|
|
PHOLD(l);
|
2002-05-09 19:44:44 +04:00
|
|
|
|
2003-01-18 13:06:22 +03:00
|
|
|
error = process_read_fpregs(l, &r);
|
2002-05-09 19:44:44 +04:00
|
|
|
if (error == 0)
|
|
|
|
error = uiomove(kv, kl, uio);
|
|
|
|
if (error == 0 && uio->uio_rw == UIO_WRITE) {
|
2003-01-18 13:06:22 +03:00
|
|
|
if (l->l_stat != LSSTOP)
|
2002-05-09 19:44:44 +04:00
|
|
|
error = EBUSY;
|
|
|
|
else
|
2003-01-18 13:06:22 +03:00
|
|
|
error = process_write_fpregs(l, &r);
|
2002-05-09 19:44:44 +04:00
|
|
|
}
|
|
|
|
|
2003-01-18 13:06:22 +03:00
|
|
|
PRELE(l);
|
2002-05-09 19:44:44 +04:00
|
|
|
|
|
|
|
uio->uio_offset = 0;
|
|
|
|
return (error);
|
|
|
|
#else
|
|
|
|
return (EINVAL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-06-30 02:28:00 +04:00
|
|
|
process_validfpregs(p)
|
|
|
|
struct proc *p;
|
2002-05-09 19:44:44 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
#if defined(PT_SETFPREGS) || defined(PT_GETFPREGS)
|
|
|
|
return ((p->p_flag & P_SYSTEM) == 0);
|
|
|
|
#else
|
|
|
|
return (0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-06-30 02:28:00 +04:00
|
|
|
process_domem(curp, p, uio)
|
|
|
|
struct proc *curp; /* tracer */
|
|
|
|
struct proc *p; /* traced */
|
2002-05-09 19:44:44 +04:00
|
|
|
struct uio *uio;
|
|
|
|
{
|
2004-05-05 01:33:40 +04:00
|
|
|
struct vmspace *vm;
|
2002-05-09 19:44:44 +04:00
|
|
|
int error;
|
|
|
|
|
|
|
|
size_t len;
|
|
|
|
#ifdef PMAP_NEED_PROCWR
|
|
|
|
vaddr_t addr;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
len = uio->uio_resid;
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
#ifdef PMAP_NEED_PROCWR
|
|
|
|
addr = uio->uio_offset;
|
|
|
|
#endif
|
|
|
|
|
2003-06-30 02:28:00 +04:00
|
|
|
if ((error = process_checkioperm(curp, p)) != 0)
|
2002-05-09 19:44:44 +04:00
|
|
|
return (error);
|
|
|
|
|
2004-05-05 01:33:40 +04:00
|
|
|
vm = p->p_vmspace;
|
|
|
|
|
|
|
|
simple_lock(&vm->vm_map.ref_lock);
|
|
|
|
if ((p->p_flag & P_WEXIT) || vm->vm_refcnt < 1)
|
|
|
|
error = EFAULT;
|
|
|
|
if (error == 0)
|
|
|
|
p->p_vmspace->vm_refcnt++; /* XXX */
|
|
|
|
simple_unlock(&vm->vm_map.ref_lock);
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
error = uvm_io(&vm->vm_map, uio);
|
|
|
|
uvmspace_free(vm);
|
2002-05-09 19:44:44 +04:00
|
|
|
|
|
|
|
#ifdef PMAP_NEED_PROCWR
|
2004-03-13 21:43:18 +03:00
|
|
|
if (error == 0 && uio->uio_rw == UIO_WRITE)
|
2002-05-09 19:44:44 +04:00
|
|
|
pmap_procwr(p, addr, len);
|
|
|
|
#endif
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ensure that a process has permission to perform I/O on another.
|
|
|
|
* Arguments:
|
|
|
|
* p The process wishing to do the I/O (the tracer).
|
|
|
|
* t The process who's memory/registers will be read/written.
|
|
|
|
*/
|
|
|
|
int
|
2003-06-30 02:28:00 +04:00
|
|
|
process_checkioperm(p, t)
|
|
|
|
struct proc *p, *t;
|
2002-05-09 19:44:44 +04:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* You cannot attach to a processes mem/regs if:
|
|
|
|
*
|
|
|
|
* (1) It is currently exec'ing
|
|
|
|
*/
|
|
|
|
if (ISSET(t->p_flag, P_INEXEC))
|
|
|
|
return (EAGAIN);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* (2) it's not owned by you, or is set-id on exec
|
|
|
|
* (unless you're root), or...
|
|
|
|
*/
|
|
|
|
if ((t->p_cred->p_ruid != p->p_cred->p_ruid ||
|
|
|
|
ISSET(t->p_flag, P_SUGID)) &&
|
|
|
|
(error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* (3) ...it's init, which controls the security level
|
|
|
|
* of the entire system, and the system was not
|
|
|
|
* compiled with permanetly insecure mode turned on.
|
|
|
|
*/
|
|
|
|
if (t == initproc && securelevel > -1)
|
|
|
|
return (EPERM);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* (4) the tracer is chrooted, and its root directory is
|
|
|
|
* not at or above the root directory of the tracee
|
|
|
|
*/
|
2003-06-30 02:28:00 +04:00
|
|
|
if (!proc_isunder(t, p))
|
2002-05-09 19:44:44 +04:00
|
|
|
return (EPERM);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|