[PATCH net] netvsc: add rcu_read locking to netvsc callback

Subsystems: hyper-v/azure core and drivers, networking drivers, the rest

STALE3508d

2 messages, 2 authors, 2017-01-11 · open the first message on its own page

[PATCH net] netvsc: add rcu_read locking to netvsc callback

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2017-01-10 15:50:27

Lockdep finds a case where netvsc receive processing is incorrectly
assuming it is in RCU safe zone. The driver is using RCU to handle
VF reference but RCU read lock not held.

Fixes 0c9d3ba9a87b ("hv_netvsc: use RCU to protect vf_netdev")

Signed-off-by: Stephen Hemminger <redacted>
---
 drivers/net/hyperv/netvsc_drv.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index c9414c054852..fcab8019dda0 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -659,6 +659,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
 	 * policy filters on the host). Deliver these via the VF
 	 * interface in the guest.
 	 */
+	rcu_read_lock();
 	vf_netdev = rcu_dereference(net_device_ctx->vf_netdev);
 	if (vf_netdev && (vf_netdev->flags & IFF_UP))
 		net = vf_netdev;
@@ -667,6 +668,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
 	skb = netvsc_alloc_recv_skb(net, packet, csum_info, *data, vlan_tci);
 	if (unlikely(!skb)) {
 		++net->stats.rx_dropped;
+		rcu_read_unlock();
 		return NVSP_STAT_FAIL;
 	}
 
@@ -696,6 +698,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
 	 * TODO - use NAPI?
 	 */
 	netif_rx(skb);
+	rcu_read_unlock();
 
 	return 0;
 }
-- 
2.11.0

Re: [PATCH net] netvsc: add rcu_read locking to netvsc callback

From: David Miller <davem@davemloft.net>
Date: 2017-01-11 02:06:22

From: Stephen Hemminger <stephen@networkplumber.org>
Date: Tue, 10 Jan 2017 07:50:16 -0800
Lockdep finds a case where netvsc receive processing is incorrectly
assuming it is in RCU safe zone. The driver is using RCU to handle
VF reference but RCU read lock not held.

Fixes 0c9d3ba9a87b ("hv_netvsc: use RCU to protect vf_netdev")

Signed-off-by: Stephen Hemminger <redacted>
Fixes tag must have a colon character after "Fixes", you must also
not put any empty lines in between the Fixes tag and the other
tags like signoffs.

Futhermore 0c9d3ba9a87b is not a valid GIT SHA1 ID.

[davem@kkuri net]$ git describe 0c9d3ba9a87b
fatal: Not a valid object name 0c9d3ba9a87b
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help