Skip to content

Commit 0719e72

Browse files
shemmingerdavem330
authored andcommitted
netvsc: add rcu_read locking to netvsc callback
The receive callback (in tasklet context) is using RCU to get reference to associated VF network device but this is not safe. RCU read lock needs to be held. Found by running with full lockdep debugging enabled. Fixes: f207c10 ("hv_netvsc: use RCU to protect vf_netdev") Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4ecb1d8 commit 0719e72

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/net/hyperv/netvsc_drv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
659659
* policy filters on the host). Deliver these via the VF
660660
* interface in the guest.
661661
*/
662+
rcu_read_lock();
662663
vf_netdev = rcu_dereference(net_device_ctx->vf_netdev);
663664
if (vf_netdev && (vf_netdev->flags & IFF_UP))
664665
net = vf_netdev;
@@ -667,6 +668,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
667668
skb = netvsc_alloc_recv_skb(net, packet, csum_info, *data, vlan_tci);
668669
if (unlikely(!skb)) {
669670
++net->stats.rx_dropped;
671+
rcu_read_unlock();
670672
return NVSP_STAT_FAIL;
671673
}
672674

@@ -696,6 +698,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
696698
* TODO - use NAPI?
697699
*/
698700
netif_rx(skb);
701+
rcu_read_unlock();
699702

700703
return 0;
701704
}

0 commit comments

Comments
 (0)