diff options
author | kib <kib@FreeBSD.org> | 2011-11-18 09:12:26 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2011-11-18 09:12:26 +0000 |
commit | b49a65685440a2621d5d334b580d98b6d2e934a7 (patch) | |
tree | 2947b2e820c322b723e3a4a24ae2b79191b3f1ec /sys/kern/kern_thread.c | |
parent | 6332d67cd9b3ba8b163b2d90c5e405684ba4d052 (diff) | |
download | FreeBSD-src-b49a65685440a2621d5d334b580d98b6d2e934a7.zip FreeBSD-src-b49a65685440a2621d5d334b580d98b6d2e934a7.tar.gz |
Consistently use process spin lock for protection of the
p->p_boundary_count. Race could cause the execve(2) from the threaded
process to hung since thread boundary counter was incorrect and
single-threading never finished.
Reported by: pluknet, pho
Tested by: pho
MFC after: 1 week
Diffstat (limited to 'sys/kern/kern_thread.c')
-rw-r--r-- | sys/kern/kern_thread.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 29bdaa2..d9df5c3 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -566,6 +566,8 @@ calc_remaining(struct proc *p, int mode) { int remaining; + PROC_LOCK_ASSERT(p, MA_OWNED); + PROC_SLOCK_ASSERT(p, MA_OWNED); if (mode == SINGLE_EXIT) remaining = p->p_numthreads; else if (mode == SINGLE_BOUNDARY) @@ -819,8 +821,11 @@ thread_suspend_check(int return_instead) td->td_flags &= ~TDF_BOUNDARY; thread_unlock(td); PROC_LOCK(p); - if (return_instead == 0) + if (return_instead == 0) { + PROC_SLOCK(p); p->p_boundary_count--; + PROC_SUNLOCK(p); + } } return (0); } |