svn commit: r348988 - stable/12/sys/kern

Konstantin Belousov kib at FreeBSD.org
Wed Jun 12 11:09:34 UTC 2019


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


More information about the svn-src-all mailing list