The patch below does not apply to the 4.14-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <stable@xxxxxxxxxxxxxxx>. To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-4.14.y git checkout FETCH_HEAD git cherry-pick -x 25266128fe16d5632d43ada34c847d7b8daba539 # <resolve conflicts, build, test, etc.> git commit -s git send-email --to '<stable@xxxxxxxxxxxxxxx>' --in-reply-to '2023080152-roundish-doornail-415a@gregkh' --subject-prefix 'PATCH 4.14.y' HEAD^.. Possible dependencies: 25266128fe16 ("virtio-net: fix race between set queues and probe") 50c0ada627f5 ("virtio-net: fix race between ndo_open() and virtio_device_ready()") c7114b1249fa ("drivers/net/virtio_net: Added basic RSS support.") a02e8964eaf9 ("virtio-net: ethtool configurable LRO") 0c465be183c7 ("virtio_net: ethtool tx napi configuration") ba5e4426e80e ("virtio_net: Extend virtio to use VF datapath when available") 9805069d14c1 ("virtio_net: Introduce VIRTIO_NET_F_STANDBY feature bit") cfc80d9a1163 ("net: Introduce net_failover driver") f4ee703ace84 ("virtio_net: sparse annotation fix") d7fad4c840f3 ("virtio_net: fix adding vids on big-endian") 12e571693837 ("virtio_net: split out ctrl buffer") faa9b39f0e9d ("virtio_net: propagate linkspeed/duplex settings from the hypervisor") 754b8a21a96d ("virtio_net: setup xdp_rxq_info") 83c9e13aa39a ("netdevsim: add software driver for testing offloads") e69b6c02b4c3 ("net: Add support for networking over Thunderbolt cable") 186b3c998c50 ("virtio-net: support XDP_REDIRECT") 312403453532 ("virtio-net: add packet len average only when needed during XDP") 9457642a405f ("virtio-net: remove unnecessary parameter of virtnet_xdp_xmit()") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 25266128fe16d5632d43ada34c847d7b8daba539 Mon Sep 17 00:00:00 2001 From: Jason Wang <jasowang@xxxxxxxxxx> Date: Tue, 25 Jul 2023 03:20:49 -0400 Subject: [PATCH] virtio-net: fix race between set queues and probe A race were found where set_channels could be called after registering but before virtnet_set_queues() in virtnet_probe(). Fixing this by moving the virtnet_set_queues() before netdevice registering. While at it, use _virtnet_set_queues() to avoid holding rtnl as the device is not even registered at that time. Cc: stable@xxxxxxxxxxxxxxx Fixes: a220871be66f ("virtio-net: correctly enable multiqueue") Signed-off-by: Jason Wang <jasowang@xxxxxxxxxx> Acked-by: Michael S. Tsirkin <mst@xxxxxxxxxx> Reviewed-by: Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20230725072049.617289-1-jasowang@xxxxxxxxxx Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 0db14f6b87d3..1270c8d23463 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -4219,6 +4219,8 @@ static int virtnet_probe(struct virtio_device *vdev) if (vi->has_rss || vi->has_rss_hash_report) virtnet_init_default_rss(vi); + _virtnet_set_queues(vi, vi->curr_queue_pairs); + /* serialize netdev register + virtio_device_ready() with ndo_open() */ rtnl_lock(); @@ -4257,8 +4259,6 @@ static int virtnet_probe(struct virtio_device *vdev) goto free_unregister_netdev; } - virtnet_set_queues(vi, vi->curr_queue_pairs); - /* Assume link up if device can't report link status, otherwise get link status from config. */ netif_carrier_off(dev);