lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220811080258.79398-3-xuanzhuo@linux.alibaba.com>
Date:   Thu, 11 Aug 2022 16:02:58 +0800
From:   Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
To:     virtualization@...ts.linux-foundation.org
Cc:     "Michael S. Tsirkin" <mst@...hat.com>,
        Jason Wang <jasowang@...hat.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
        Kangjie Xu <kangjie.xu@...ux.alibaba.com>
Subject: [PATCH 2/2] virtio_net: fix for stuck when change tx ring size with dev down

When dev is set to DOWN state, napi has been disabled, if we modify the
ring size at this time, we should not call napi_disable() again, which
will cause stuck.

And all operations are under the protection of rtnl_lock, so there is no
need to consider concurrency issues.

Reported-by: Kangjie Xu <kangjie.xu@...ux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
---
 drivers/net/virtio_net.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 17687eb3f0bd..d9c434b00e9b 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1915,12 +1915,14 @@ static int virtnet_rx_resize(struct virtnet_info *vi,
 static int virtnet_tx_resize(struct virtnet_info *vi,
 			     struct send_queue *sq, u32 ring_num)
 {
+	bool running = netif_running(vi->dev);
 	struct netdev_queue *txq;
 	int err, qindex;
 
 	qindex = sq - vi->sq;
 
-	virtnet_napi_tx_disable(&sq->napi);
+	if (running)
+		virtnet_napi_tx_disable(&sq->napi);
 
 	txq = netdev_get_tx_queue(vi->dev, qindex);
 
@@ -1946,7 +1948,8 @@ static int virtnet_tx_resize(struct virtnet_info *vi,
 	netif_tx_wake_queue(txq);
 	__netif_tx_unlock_bh(txq);
 
-	virtnet_napi_tx_enable(vi, sq->vq, &sq->napi);
+	if (running)
+		virtnet_napi_tx_enable(vi, sq->vq, &sq->napi);
 	return err;
 }
 
-- 
2.31.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ