mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Don't allow one to trace an ancestor when already traced.
PR: kern/29741 Submitted by: Dave Zarzycki <zarzycki@FreeBSD.org> Fix from: Tim J. Robbins <tim@robbins.dropbear.id.au> MFC After: 2 weeks
This commit is contained in:
parent
51a7b740a1
commit
46e12b42fe
1 changed files with 14 additions and 1 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue