diff options
| author | Alfred Perlstein <alfred@FreeBSD.org> | 2002-04-14 17:12:55 +0000 |
|---|---|---|
| committer | Alfred Perlstein <alfred@FreeBSD.org> | 2002-04-14 17:12:55 +0000 |
| commit | 46e12b42fed11fd1d8a44671ef98d462ea5e42b7 (patch) | |
| tree | 86cf9a464fc95764601e09b652b83648c7a83ea5 /sys/kern/sys_process.c | |
| parent | 51a7b740a11434580f649a98c2b44b98d60e4292 (diff) | |
Notes
Diffstat (limited to 'sys/kern/sys_process.c')
| -rw-r--r-- | sys/kern/sys_process.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 42cdebcc8c8b..3561f6ff465b 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -332,11 +332,13 @@ ptrace(struct thread *td, struct ptrace_args *uap) struct fpreg fpreg; struct reg reg; } r; - struct proc *p; + struct proc *curp, *p, *pp; struct thread *td2; int error, write; int proctree_locked = 0; + curp = td->td_proc; + /* * Do copyin() early before getting locks and lock proctree before * locking the process. @@ -422,6 +424,17 @@ ptrace(struct thread *td, struct ptrace_args *uap) goto fail; } + /* Can't trace an ancestor if you're being traced. */ + if (curp->p_flag & P_TRACED) { + for (pp = curp->p_pptr; pp != NULL; pp = pp->p_pptr) { + if (pp == p) { + error = EINVAL; + goto fail; + } + } + } + + /* OK */ break; |
