aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2025-11-06 19:25:23 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2025-11-11 08:54:05 +0000
commite1c6f4cb9bd29358c2b2fe249af9a2f9626b0670 (patch)
treeb83212ce2fffc40808bd7649d440e434e57d40ec
parentdf84867e8af49437bdc76a0df41d78f5a362cd24 (diff)
kern_thread: thread_suspend_check(1) must never suspend
Reported by: bdrewery Reviewed by: bdrewery, markj Tested by: bdrewery, pho PR: 290843 Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D53624
-rw-r--r--sys/kern/kern_thread.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index 3180c66cb42b..4f9053460455 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -1447,6 +1447,14 @@ thread_suspend_check(int return_instead)
}
/*
+ * We might get here with return_instead == 1 if
+ * other checks missed it. Then we must not suspend
+ * regardless of P_SHOULDSTOP() or debugger request.
+ */
+ if (return_instead)
+ return (EINTR);
+
+ /*
* If the process is waiting for us to exit,
* this thread should just suicide.
* Assumes that P_SINGLE_EXIT implies P_STOPPED_SINGLE.
@@ -1481,10 +1489,9 @@ thread_suspend_check(int return_instead)
* gets taken off all queues.
*/
thread_suspend_one(td);
- if (return_instead == 0) {
- p->p_boundary_count++;
- td->td_flags |= TDF_BOUNDARY;
- }
+ MPASS(!return_instead);
+ p->p_boundary_count++;
+ td->td_flags |= TDF_BOUNDARY;
PROC_SUNLOCK(p);
mi_switch(SW_INVOL | SWT_SUSPEND);
PROC_LOCK(p);