Path: blob/main/website/static/security/patches/EN-10:02/sched_ule.patch
18096 views
Index: sys/kern/sched_ule.c1===================================================================2--- sys/kern/sched_ule.c (revision 202744)3+++ sys/kern/sched_ule.c (working copy)4@@ -1822,18 +1822,24 @@5*/6spinlock_enter();7thread_block_switch(td); /* This releases the lock on tdq. */8- TDQ_LOCK(tdn);9- tdq_add(tdn, td, flags);10- tdq_notify(td->td_sched);11+12/*13- * After we unlock tdn the new cpu still can't switch into this14- * thread until we've unblocked it in cpu_switch(). The lock15- * pointers may match in the case of HTT cores. Don't unlock here16- * or we can deadlock when the other CPU runs the IPI handler.17+ * Acquire both run-queue locks before placing the thread on the new18+ * run-queue to avoid deadlocks created by placing a thread with a19+ * blocked lock on the run-queue of a remote processor. The deadlock20+ * occurs when a third processor attempts to lock the two queues in21+ * question while the target processor is spinning with its own22+ * run-queue lock held while waiting for the blocked lock to clear.23*/24- if (TDQ_LOCKPTR(tdn) != TDQ_LOCKPTR(tdq)) {25+ if (TDQ_LOCKPTR(tdn) == TDQ_LOCKPTR(tdq)) {26+ TDQ_LOCK(tdq);27+ tdq_add(tdn, td, flags);28+ tdq_notify(td->td_sched);29+ } else {30+ tdq_lock_pair(tdn, tdq);31+ tdq_add(tdn, td, flags);32+ tdq_notify(td->td_sched);33TDQ_UNLOCK(tdn);34- TDQ_LOCK(tdq);35}36spinlock_exit();37#endif383940