Skip to contentSkip to conversation

netvsc: fix race during initialization

PATCH Applied Stephen Hemminger 2 participants 2 messages Mar 16, 2017 – Mar 17, 2017

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

PATCH 1/1 netvsc: fix race during initialization

When device is being setup on boot, there is a small race where network device callback is registered, but the netvsc_device pointer is not set yet. This can cause a NULL ptr dereference if packet arrives during this window.

Fixes 46b4f7f5d1f7 ("netvsc: eliminate per-device outstanding send counter")

---
Applies to 4.11 only, not in earlier versions.
net-next needs different patch

 drivers/net/hyperv/netvsc.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/hyperv/netvsc.c +5 -2
index 4c1d8cca247b..8dd0b8770328 100644
@@ -1231,8 +1231,11 @@ void netvsc_channel_cb(void *context)
 		return;
 
 	net_device = net_device_to_netvsc_device(ndev);
-	if (unlikely(net_device->destroy) &&
-	    netvsc_channel_idle(net_device, q_idx))
+	if (unlikely(!net_device))
+		return;
+
+	if (unlikely(net_device->destroy &&
+		     netvsc_channel_idle(net_device, q_idx)))
 		return;
 
 	/* commit_rd_index() -> hv_signal_on_read() needs this. */
Signature · 1 line
2.11.0
maintainer Applied
#1 lore raw

From: Stephen Hemminger <[email protected]>
Date: Thu, 16 Mar 2017 12:21:32 -0700

Quoted 10 lines

When device is being setup on boot, there is a small race where network device callback is registered, but the netvsc_device pointer is not set yet. This can cause a NULL ptr dereference if packet arrives during this window.

Fixes 46b4f7f5d1f7 ("netvsc: eliminate per-device outstanding send counter")

---
Applies to 4.11 only, not in earlier versions.
net-next needs different patch

Applied, thanks Stephen.