svn commit: r350357 - stable/11/sys/kern

Konstantin Belousov kib at FreeBSD.org
Fri Jul 26 10:43:08 UTC 2019


Author: kib
Date: Fri Jul 26 10:43:07 2019
New Revision: 350357
URL: https://svnweb.freebsd.org/changeset/base/350357

Log:
  MFC r348360:
  Do not go into sleep in sleepq_catch_signals() when SIGSTOP from
  PT_ATTACH was consumed.
  
  PR:	231445

Modified:
  stable/11/sys/kern/kern_sig.c
  stable/11/sys/kern/subr_sleepqueue.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/kern_sig.c
==============================================================================
--- stable/11/sys/kern/kern_sig.c	Fri Jul 26 10:38:20 2019	(r350356)
+++ stable/11/sys/kern/kern_sig.c	Fri Jul 26 10:43:07 2019	(r350357)
@@ -2588,7 +2588,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/11/sys/kern/subr_sleepqueue.c
==============================================================================
--- stable/11/sys/kern/subr_sleepqueue.c	Fri Jul 26 10:38:20 2019	(r350356)
+++ stable/11/sys/kern/subr_sleepqueue.c	Fri Jul 26 10:43:07 2019	(r350357)
@@ -494,6 +494,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