Skip to content

Commit c392d60

Browse files
jasowangkuba-moo
authored andcommitted
virtio-net: synchronize probe with ndo_set_features
We calculate guest offloads during probe without the protection of rtnl_lock. This lead to race between probe and ndo_set_features. Fix this by moving the calculation under the rtnl_lock. Fixes: 3f93522 ("virtio-net: switch off offloads on demand if possible on XDP set") Acked-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Jason Wang <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent df28de7 commit c392d60

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/net/virtio_net.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6606,6 +6606,11 @@ static int virtnet_probe(struct virtio_device *vdev)
66066606
netif_carrier_on(dev);
66076607
}
66086608

6609+
for (i = 0; i < ARRAY_SIZE(guest_offloads); i++)
6610+
if (virtio_has_feature(vi->vdev, guest_offloads[i]))
6611+
set_bit(guest_offloads[i], &vi->guest_offloads);
6612+
vi->guest_offloads_capable = vi->guest_offloads;
6613+
66096614
rtnl_unlock();
66106615

66116616
err = virtnet_cpu_notif_add(vi);
@@ -6614,11 +6619,6 @@ static int virtnet_probe(struct virtio_device *vdev)
66146619
goto free_unregister_netdev;
66156620
}
66166621

6617-
for (i = 0; i < ARRAY_SIZE(guest_offloads); i++)
6618-
if (virtio_has_feature(vi->vdev, guest_offloads[i]))
6619-
set_bit(guest_offloads[i], &vi->guest_offloads);
6620-
vi->guest_offloads_capable = vi->guest_offloads;
6621-
66226622
pr_debug("virtnet: registered device %s with %d RX and TX vq's\n",
66236623
dev->name, max_queue_pairs);
66246624

0 commit comments

Comments
 (0)