DragonFlyBSD Kernel Audit
DF-2729 / fix.diff
← back to finding ↓ download raw
--- a/sys/kern/lwkt_thread.c
+++ b/sys/kern/lwkt_thread.c
@@ -1290,7 +1290,14 @@
 
     KASSERT(td != &td->td_gd->gd_idlethread,
 	    ("lwkt_schedule(): scheduling gd_idlethread is illegal!"));
-    KKASSERT((td->td_flags & TDF_MIGRATING) == 0);
+    /*
+     * NOTE: Do NOT assert TDF_MIGRATING is clear here.  A wakeup
+     * IPI can be routed to the thread's old home cpu while a
+     * push/pull migration (lwkt_setcpu_self / lwkt_giveaway +
+     * lwkt_acquire) is in flight.  _lwkt_enqueue() already
+     * swallows schedules of TDF_MIGRATING threads by design; the
+     * migration completion path enqueues it.
+     */
     crit_enter_gd(mygd);
     KKASSERT(td->td_lwp == NULL ||
 	     (td->td_lwp->lwp_mpflags & LWP_MP_ONRUNQ) == 0);