Skip to content

Commit 75a884e

Browse files
jasowangBrian Maly
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]> (cherry picked from commit c392d60) Orabug: 36637822 Reviewed-by: Dongli Zhang <[email protected]> Signed-off-by: Venkat Venkatsubra <[email protected]> Signed-off-by: Brian Maly <[email protected]>
1 parent cf7313e commit 75a884e

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
@@ -3416,6 +3416,11 @@ static int virtnet_probe(struct virtio_device *vdev)
34163416
netif_carrier_on(dev);
34173417
}
34183418

3419+
for (i = 0; i < ARRAY_SIZE(guest_offloads); i++)
3420+
if (virtio_has_feature(vi->vdev, guest_offloads[i]))
3421+
set_bit(guest_offloads[i], &vi->guest_offloads);
3422+
vi->guest_offloads_capable = vi->guest_offloads;
3423+
34193424
rtnl_unlock();
34203425

34213426
err = virtnet_cpu_notif_add(vi);
@@ -3424,11 +3429,6 @@ static int virtnet_probe(struct virtio_device *vdev)
34243429
goto free_unregister_netdev;
34253430
}
34263431

3427-
for (i = 0; i < ARRAY_SIZE(guest_offloads); i++)
3428-
if (virtio_has_feature(vi->vdev, guest_offloads[i]))
3429-
set_bit(guest_offloads[i], &vi->guest_offloads);
3430-
vi->guest_offloads_capable = vi->guest_offloads;
3431-
34323432
pr_debug("virtnet: registered device %s with %d RX and TX vq's\n",
34333433
dev->name, max_queue_pairs);
34343434

0 commit comments

Comments
 (0)