From c41dd2fa032006f68be7540069c4cc9c96cf1aa1 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 1 Aug 2023 07:57:30 +0200 Subject: [PATCH] 5.15-stable patches added patches: virtio-net-fix-race-between-set-queues-and-probe.patch --- queue-5.15/series | 1 + ...ix-race-between-set-queues-and-probe.patch | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 queue-5.15/virtio-net-fix-race-between-set-queues-and-probe.patch diff --git a/queue-5.15/series b/queue-5.15/series index b01fc80157f..5e1d23a211a 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -137,3 +137,4 @@ irq-bcm6345-l1-do-not-assume-a-fixed-block-to-cpu-ma.patch irqchip-gic-v4.1-properly-lock-vpes-when-doing-a-dir.patch locking-rtmutex-fix-task-pi_waiters-integrity.patch kvm-x86-disallow-kvm_set_sregs-2-if-incoming-cr0-is-.patch +virtio-net-fix-race-between-set-queues-and-probe.patch diff --git a/queue-5.15/virtio-net-fix-race-between-set-queues-and-probe.patch b/queue-5.15/virtio-net-fix-race-between-set-queues-and-probe.patch new file mode 100644 index 00000000000..3150e8fea98 --- /dev/null +++ b/queue-5.15/virtio-net-fix-race-between-set-queues-and-probe.patch @@ -0,0 +1,47 @@ +From 25266128fe16d5632d43ada34c847d7b8daba539 Mon Sep 17 00:00:00 2001 +From: Jason Wang +Date: Tue, 25 Jul 2023 03:20:49 -0400 +Subject: virtio-net: fix race between set queues and probe + +From: Jason Wang + +commit 25266128fe16d5632d43ada34c847d7b8daba539 upstream. + +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@vger.kernel.org +Fixes: a220871be66f ("virtio-net: correctly enable multiqueue") +Signed-off-by: Jason Wang +Acked-by: Michael S. Tsirkin +Reviewed-by: Xuan Zhuo +Link: https://lore.kernel.org/r/20230725072049.617289-1-jasowang@redhat.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/virtio_net.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/net/virtio_net.c ++++ b/drivers/net/virtio_net.c +@@ -3319,6 +3319,8 @@ static int virtnet_probe(struct virtio_d + } + } + ++ _virtnet_set_queues(vi, vi->curr_queue_pairs); ++ + /* serialize netdev register + virtio_device_ready() with ndo_open() */ + rtnl_lock(); + +@@ -3339,8 +3341,6 @@ static int virtnet_probe(struct virtio_d + 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); -- 2.47.3