mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Don't set P2_PTRACE_FSTP in a process that invokes ptrace(PT_TRACE_ME).
Such processes are stopped synchronously by a direct call to ptracestop(SIGTRAP) upon exec. P2_PTRACE_FSTP causes the exec()ing thread to suspend itself while waiting for a SIGSTOP that never arrives. Reviewed by: kib MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D7576
This commit is contained in:
parent
bd6ff0807e
commit
e5574e0966
3 changed files with 7 additions and 6 deletions
|
|
@ -1074,7 +1074,7 @@ fork_return(struct thread *td, struct trapframe *frame)
|
|||
* parent's children, do it now.
|
||||
*/
|
||||
dbg = p->p_pptr->p_pptr;
|
||||
proc_set_traced(p);
|
||||
proc_set_traced(p, true);
|
||||
CTR2(KTR_PTRACE,
|
||||
"fork_return: attaching to new child pid %d: oppid %d",
|
||||
p->p_pid, p->p_oppid);
|
||||
|
|
|
|||
|
|
@ -693,12 +693,13 @@ sys_ptrace(struct thread *td, struct ptrace_args *uap)
|
|||
#endif
|
||||
|
||||
void
|
||||
proc_set_traced(struct proc *p)
|
||||
proc_set_traced(struct proc *p, bool stop)
|
||||
{
|
||||
|
||||
PROC_LOCK_ASSERT(p, MA_OWNED);
|
||||
p->p_flag |= P_TRACED;
|
||||
p->p_flag2 |= P2_PTRACE_FSTP;
|
||||
if (stop)
|
||||
p->p_flag2 |= P2_PTRACE_FSTP;
|
||||
p->p_ptevents = PTRACE_DEFAULT;
|
||||
p->p_oppid = p->p_pptr->p_pid;
|
||||
}
|
||||
|
|
@ -910,7 +911,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
|
|||
switch (req) {
|
||||
case PT_TRACE_ME:
|
||||
/* set my trace flag and "owner" so it can read/write me */
|
||||
proc_set_traced(p);
|
||||
proc_set_traced(p, false);
|
||||
if (p->p_flag & P_PPWAIT)
|
||||
p->p_flag |= P_PPTRACE;
|
||||
CTR1(KTR_PTRACE, "PT_TRACE_ME: pid %d", p->p_pid);
|
||||
|
|
@ -927,7 +928,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
|
|||
* The old parent is remembered so we can put things back
|
||||
* on a "detach".
|
||||
*/
|
||||
proc_set_traced(p);
|
||||
proc_set_traced(p, true);
|
||||
if (p->p_pptr != td->td_proc) {
|
||||
proc_reparent(p, td->td_proc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1010,7 +1010,7 @@ void proc_linkup(struct proc *p, struct thread *td);
|
|||
struct proc *proc_realparent(struct proc *child);
|
||||
void proc_reap(struct thread *td, struct proc *p, int *status, int options);
|
||||
void proc_reparent(struct proc *child, struct proc *newparent);
|
||||
void proc_set_traced(struct proc *p);
|
||||
void proc_set_traced(struct proc *p, bool stop);
|
||||
struct pstats *pstats_alloc(void);
|
||||
void pstats_fork(struct pstats *src, struct pstats *dst);
|
||||
void pstats_free(struct pstats *ps);
|
||||
|
|
|
|||
Loading…
Reference in a new issue