⬢ DragonFlyBSD Kernel Audit
DF-4046 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/netif/stge/if_stge.c
+++ b/sys/dev/netif/stge/if_stge.c
@@ -1755,7 +1755,18 @@
 	struct ifnet *ifp = &sc->arpcom.ac_if;
 	struct mii_data *mii;
 
-	lwkt_serialize_enter(ifp->if_serializer);
+	/*
+	 * Never block on the serializer from the callout handler:
+	 * stge_stop() issues a synchronous callout_stop() while HOLDING
+	 * the serializer (if_stge.c:2111), so a tick parked inside
+	 * lwkt_serialize_enter deadlocks against it (AB-BA, DF-4046;
+	 * callout_stop sleeps on "costp", kern_timeout.c:920).  Retry
+	 * on the next tick instead.
+	 */
+	if (lwkt_serialize_try(ifp->if_serializer) == 0) {
+		callout_reset(&sc->sc_tick_ch, 1, stge_tick, sc);
+		return;
+	}
 
 	mii = device_get_softc(sc->sc_miibus);
 	mii_tick(mii);