svn commit: r333758 - head/sys/kern
Matt Macy
mmacy at FreeBSD.org
Thu May 17 19:41:59 UTC 2018
Author: mmacy
Date: Thu May 17 19:41:58 2018
New Revision: 333758
URL: https://svnweb.freebsd.org/changeset/base/333758
Log:
epoch(9): fix potential deadlock
Don't acquire a waiting thread's lock while holding our own
Approved by: sbruno
Modified:
head/sys/kern/subr_epoch.c
Modified: head/sys/kern/subr_epoch.c
==============================================================================
--- head/sys/kern/subr_epoch.c Thu May 17 19:30:57 2018 (r333757)
+++ head/sys/kern/subr_epoch.c Thu May 17 19:41:58 2018 (r333758)
@@ -407,9 +407,13 @@ epoch_block_handler(struct ck_epoch *global __unused,
* restore on exit from epoch_wait().
*/
if (!TD_IS_INHIBITED(tdwait) && tdwait->td_priority > td->td_priority) {
+ critical_enter();
+ thread_unlock(td);
thread_lock(tdwait);
sched_prio(tdwait, td->td_priority);
thread_unlock(tdwait);
+ thread_lock(td);
+ critical_exit();
}
if (TD_IS_INHIBITED(tdwait) && TD_ON_LOCK(tdwait) &&
((ts = tdwait->td_blocked) != NULL)) {
More information about the svn-src-head
mailing list