This is a note to let you know that I've just added the patch titled virtio-net: synchronize probe with ndo_set_features to the 6.11-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: virtio-net-synchronize-probe-with-ndo_set_features.patch and it can be found in the queue-6.11 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 0b52ac2da9f6fbe77ac3572e5b916f16a54144e6 Author: Jason Wang <jasowang@xxxxxxxxxx> Date: Wed Aug 14 13:22:28 2024 +0800 virtio-net: synchronize probe with ndo_set_features [ Upstream commit c392d6019398315526b0b508282f87c7b2318c72 ] 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: 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set") Acked-by: Michael S. Tsirkin <mst@xxxxxxxxxx> Signed-off-by: Jason Wang <jasowang@xxxxxxxxxx> Link: https://patch.msgid.link/20240814052228.4654-5-jasowang@xxxxxxxxxx Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 60833e7b5a935..6f4781ec2b369 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -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);