Skip to contentSkip to conversation

netvsc: fix deadlock betwen link status and removal

PATCH In review Stephen Hemminger 2 participants 2 messages Aug 24, 2017 – Aug 25, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netvsc: fix deadlock betwen link status and removal

There is a deadlock possible when canceling the link status delayed work queue. The removal process is run with RTNL held, and the link status callback is acquring RTNL.

Resolve the issue by using trylock and rescheduling. If cancel is in process, that block it from happening.

Fixes 122a5f6410f4 ("staging: hv: use delayed_work for netvsc_send_garp()")

---
This should be queued for stable as well. Problem has existed back to 3.10

 drivers/net/hyperv/netvsc_drv.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/hyperv/netvsc_drv.c +6 -1
index 0d78727f1a14..d91cbc6c3ca4 100644
@@ -1269,7 +1269,12 @@ static void netvsc_link_change(struct work_struct *w)
 	bool notify = false, reschedule = false;
 	unsigned long flags, next_reconfig, delay;
 
-	rtnl_lock();
+	/* if changes are happening, comeback later */
+	if (!rtnl_trylock()) {
+		schedule_delayed_work(&ndev_ctx->dwork, LINKCHANGE_INT);
+		return;
+	}
+
 	net_device = rtnl_dereference(ndev_ctx->nvdev);
 	if (!net_device)
 		goto out_unlock;
Signature · 1 line
2.11.0
maintainer
#1 lore raw

From: Stephen Hemminger <[email protected]>
Date: Thu, 24 Aug 2017 16:49:16 -0700

Quoted 9 lines

There is a deadlock possible when canceling the link status delayed work queue. The removal process is run with RTNL held, and the link status callback is acquring RTNL.

Resolve the issue by using trylock and rescheduling. If cancel is in process, that block it from happening.

Fixes 122a5f6410f4 ("staging: hv: use delayed_work for netvsc_send_garp()")

Applied and queued up for -stable, thanks.