summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_thread.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2015-05-09 18:32:13 +0000
committerkib <kib@FreeBSD.org>2015-05-09 18:32:13 +0000
commite0b2902247e3c0cda8888ec51822a3131af4b18b (patch)
tree54574021582c620d4f760d8040d4f8cf0226933b /sys/kern/kern_thread.c
parent6006bf3a7dfd2f9b0bf0be6700967a1ab993b8a0 (diff)
downloadFreeBSD-src-e0b2902247e3c0cda8888ec51822a3131af4b18b.zip
FreeBSD-src-e0b2902247e3c0cda8888ec51822a3131af4b18b.tar.gz
Do not return from thread_single(SINGLE_BOUNDARY) until all stopped
thread are guarenteed to be removed from the processors. Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week
Diffstat (limited to 'sys/kern/kern_thread.c')
-rw-r--r--sys/kern/kern_thread.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index 0a93dbd..c7c0ee4 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -759,6 +759,29 @@ stopme:
PROC_LOCK(p);
PROC_SLOCK(p);
}
+ } else if (mode == SINGLE_BOUNDARY) {
+ /*
+ * Wait until all suspended threads are removed from
+ * the processors. The thread_suspend_check()
+ * increments p_boundary_count while it is still
+ * running, which makes it possible for the execve()
+ * to destroy vmspace while our other threads are
+ * still using the address space.
+ *
+ * We lock the thread, which is only allowed to
+ * succeed after context switch code finished using
+ * the address space.
+ */
+ FOREACH_THREAD_IN_PROC(p, td2) {
+ if (td2 == td)
+ continue;
+ thread_lock(td2);
+ KASSERT((td2->td_flags & TDF_BOUNDARY) != 0,
+ ("td %p not on boundary", td2));
+ KASSERT(TD_IS_SUSPENDED(td2),
+ ("td %p is not suspended", td2));
+ thread_unlock(td2);
+ }
}
PROC_SUNLOCK(p);
return (0);
OpenPOWER on IntegriCloud