Skip to content

Commit eae33a9

Browse files
jasowanggregkh
authored andcommitted
virtio-net: synchronize probe with ndo_set_features
[ Upstream commit c392d60 ] 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 <mst@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Link: https://patch.msgid.link/20240814052228.4654-5-jasowang@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent cb06b26 commit eae33a9

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

drivers/net/virtio_net.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6603,6 +6603,11 @@ static int virtnet_probe(struct virtio_device *vdev)
66036603
netif_carrier_on(dev);
66046604
}
66056605

6606+
for (i = 0; i < ARRAY_SIZE(guest_offloads); i++)
6607+
if (virtio_has_feature(vi->vdev, guest_offloads[i]))
6608+
set_bit(guest_offloads[i], &vi->guest_offloads);
6609+
vi->guest_offloads_capable = vi->guest_offloads;
6610+
66066611
rtnl_unlock();
66076612

66086613
err = virtnet_cpu_notif_add(vi);
@@ -6611,11 +6616,6 @@ static int virtnet_probe(struct virtio_device *vdev)
66116616
goto free_unregister_netdev;
66126617
}
66136618

6614-
for (i = 0; i < ARRAY_SIZE(guest_offloads); i++)
6615-
if (virtio_has_feature(vi->vdev, guest_offloads[i]))
6616-
set_bit(guest_offloads[i], &vi->guest_offloads);
6617-
vi->guest_offloads_capable = vi->guest_offloads;
6618-
66196619
pr_debug("virtnet: registered device %s with %d RX and TX vq's\n",
66206620
dev->name, max_queue_pairs);
66216621

0 commit comments

Comments
 (0)