]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
virtio-net: fix recursived rtnl_lock() during probe()
authorZigit Zo <zuozhijie@bytedance.com>
Wed, 16 Jul 2025 11:57:17 +0000 (19:57 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 17 Jul 2025 14:37:59 +0000 (07:37 -0700)
The deadlock appears in a stack trace like:

  virtnet_probe()
    rtnl_lock()
    virtio_config_changed_work()
      netdev_notify_peers()
        rtnl_lock()

It happens if the VMM sends a VIRTIO_NET_S_ANNOUNCE request while the
virtio-net driver is still probing.

The config_work in probe() will get scheduled until virtnet_open() enables
the config change notification via virtio_config_driver_enable().

Fixes: df28de7b0050 ("virtio-net: synchronize operstate with admin state on up/down")
Signed-off-by: Zigit Zo <zuozhijie@bytedance.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Link: https://patch.msgid.link/20250716115717.1472430-1-zuozhijie@bytedance.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/virtio_net.c

index 5d674eb9a0f2c60c0bf537b72ab6c736545c6a39..82b4a2a2b8c429823aa811dad099377a60933964 100644 (file)
@@ -7059,7 +7059,7 @@ static int virtnet_probe(struct virtio_device *vdev)
           otherwise get link status from config. */
        netif_carrier_off(dev);
        if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) {
-               virtnet_config_changed_work(&vi->config_work);
+               virtio_config_changed(vi->vdev);
        } else {
                vi->status = VIRTIO_NET_S_LINK_UP;
                virtnet_update_settings(vi);