Date: Wed, 12 Jun 2019 11:09:33 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348988 - stable/12/sys/kern Message-ID: <201906121109.x5CB9XIp066328@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Wed Jun 12 11:09:33 2019 New Revision: 348988 URL: https://svnweb.freebsd.org/changeset/base/348988 Log: MFC r348360: Do not go into sleep in sleepq_catch_signals() when SIGSTOP from PT_ATTACH was consumed. PR: 231445 Modified: stable/12/sys/kern/kern_sig.c stable/12/sys/kern/subr_sleepqueue.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/kern_sig.c ============================================================================== --- stable/12/sys/kern/kern_sig.c Wed Jun 12 11:06:58 2019 (r348987) +++ stable/12/sys/kern/kern_sig.c Wed Jun 12 11:09:33 2019 (r348988) @@ -2577,7 +2577,15 @@ ptracestop(struct thread *td, int sig, ksiginfo_t *si) p->p_xthread == NULL)) { p->p_xsig = sig; p->p_xthread = td; - td->td_dbgflags &= ~TDB_FSTP; + + /* + * If we are on sleepqueue already, + * let sleepqueue code decide if it + * needs to go sleep after attach. + */ + if (td->td_wchan == NULL) + td->td_dbgflags &= ~TDB_FSTP; + p->p_flag2 &= ~P2_PTRACE_FSTP; p->p_flag |= P_STOPPED_SIG | P_STOPPED_TRACE; sig_suspend_threads(td, p, 0); Modified: stable/12/sys/kern/subr_sleepqueue.c ============================================================================== --- stable/12/sys/kern/subr_sleepqueue.c Wed Jun 12 11:06:58 2019 (r348987) +++ stable/12/sys/kern/subr_sleepqueue.c Wed Jun 12 11:09:33 2019 (r348988) @@ -499,6 +499,19 @@ sleepq_catch_signals(void *wchan, int pri) } else { mtx_unlock(&ps->ps_mtx); } + + /* + * Do not go into sleep if this thread was the + * ptrace(2) attach leader. cursig() consumed + * SIGSTOP from PT_ATTACH, but we usually act + * on the signal by interrupting sleep, and + * should do that here as well. + */ + if ((td->td_dbgflags & TDB_FSTP) != 0) { + if (ret == 0) + ret = EINTR; + td->td_dbgflags &= ~TDB_FSTP; + } } /* * Lock the per-process spinlock prior to dropping the PROC_LOCK
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201906121109.x5CB9XIp066328>