diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 11c0334181e1..eea624019fff 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -279,7 +279,7 @@ static void ast_sig(struct thread *td, int tda) { struct proc *p; - int sig; + int old_boundary, sig; bool resched_sigs; p = td->td_proc; @@ -321,12 +321,15 @@ ast_sig(struct thread *td, int tda) !SIGISEMPTY(p->p_siglist)) { sigfastblock_fetch(td); PROC_LOCK(p); + old_boundary = ~TDB_BOUNDARY | (td->td_dbgflags & TDB_BOUNDARY); + td->td_dbgflags |= TDB_BOUNDARY; mtx_lock(&p->p_sigacts->ps_mtx); while ((sig = cursig(td)) != 0) { KASSERT(sig >= 0, ("sig %d", sig)); postsig(sig); } mtx_unlock(&p->p_sigacts->ps_mtx); + td->td_dbgflags &= old_boundary; PROC_UNLOCK(p); resched_sigs = true; } else { diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c index 33dd50d3d50a..36830a13e596 100644 --- a/sys/kern/subr_syscall.c +++ b/sys/kern/subr_syscall.c @@ -73,6 +73,7 @@ syscallenter(struct thread *td) traced = (p->p_flag & P_TRACED) != 0; if (__predict_false(traced || td->td_dbgflags & TDB_USERWR)) { PROC_LOCK(p); + MPASS((td->td_dbgflags & TDB_BOUNDARY) == 0); td->td_dbgflags &= ~TDB_USERWR; if (traced) td->td_dbgflags |= TDB_SCE; @@ -201,7 +202,7 @@ syscallenter(struct thread *td) td->td_retval[1]); if (__predict_false(traced)) { PROC_LOCK(p); - td->td_dbgflags &= ~TDB_SCE; + td->td_dbgflags &= ~(TDB_SCE | TDB_BOUNDARY); PROC_UNLOCK(p); } (p->p_sysent->sv_set_syscall_retval)(td, error); @@ -280,9 +281,13 @@ syscallret(struct thread *td) */ if (traced && ((td->td_dbgflags & (TDB_FORK | TDB_EXEC)) != 0 || - (p->p_ptevents & PTRACE_SCX) != 0)) + (p->p_ptevents & PTRACE_SCX) != 0)) { + MPASS((td->td_dbgflags & TDB_BOUNDARY) == 0); + td->td_dbgflags |= TDB_BOUNDARY; ptracestop(td, SIGTRAP, NULL); - td->td_dbgflags &= ~(TDB_SCX | TDB_EXEC | TDB_FORK); + } + td->td_dbgflags &= ~(TDB_SCX | TDB_EXEC | TDB_FORK | + TDB_BOUNDARY); PROC_UNLOCK(p); } } diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 1552da628b11..f17207d741c1 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -522,7 +522,8 @@ enum { #define TDB_FSTP 0x00001000 /* The thread is PT_ATTACH leader */ #define TDB_STEP 0x00002000 /* (x86) PSL_T set for PT_STEP */ #define TDB_SSWITCH 0x00004000 /* Suspended in ptracestop */ -#define TDB_COREDUMPREQ 0x00008000 /* Coredump request */ +#define TDB_BOUNDARY 0x00008000 /* ptracestop() at boundary */ +#define TDB_COREDUMPREQ 0x00010000 /* Coredump request */ /* * "Private" flags kept in td_pflags: