virtio-net: synchronize probe with ndo_set_features
[ Upstream commitc392d60193] 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:3f93522ffa("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
cb06b26bb2
commit
eae33a98b7
@@ -6603,6 +6603,11 @@ static int virtnet_probe(struct virtio_device *vdev)
|
||||
netif_carrier_on(dev);
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(guest_offloads); i++)
|
||||
if (virtio_has_feature(vi->vdev, guest_offloads[i]))
|
||||
set_bit(guest_offloads[i], &vi->guest_offloads);
|
||||
vi->guest_offloads_capable = vi->guest_offloads;
|
||||
|
||||
rtnl_unlock();
|
||||
|
||||
err = virtnet_cpu_notif_add(vi);
|
||||
@@ -6611,11 +6616,6 @@ static int virtnet_probe(struct virtio_device *vdev)
|
||||
goto free_unregister_netdev;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(guest_offloads); i++)
|
||||
if (virtio_has_feature(vi->vdev, guest_offloads[i]))
|
||||
set_bit(guest_offloads[i], &vi->guest_offloads);
|
||||
vi->guest_offloads_capable = vi->guest_offloads;
|
||||
|
||||
pr_debug("virtnet: registered device %s with %d RX and TX vq's\n",
|
||||
dev->name, max_queue_pairs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user