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: <20230430131518.2708471-4-alvaro.karsz@solid-run.com>
Date:   Sun, 30 Apr 2023 16:15:18 +0300
From:   Alvaro Karsz <alvaro.karsz@...id-run.com>
To:     mst@...hat.com, jasowang@...hat.com
Cc:     davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
        pabeni@...hat.com, virtualization@...ts.linux-foundation.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        xuanzhuo@...ux.alibaba.com,
        Alvaro Karsz <alvaro.karsz@...id-run.com>
Subject: [RFC PATCH net 3/3] virtio-net: block ethtool from converting a ring to a small ring

Stop ethtool from resizing a TX/RX ring to size less than
MAX_SKB_FRAGS + 2, if the ring was initialized with a bigger size.

We cannot convert a "normal" ring to a "small" ring in runtime.

Signed-off-by: Alvaro Karsz <alvaro.karsz@...id-run.com>
---
 drivers/net/virtio_net.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index b4441d63890..b8238eaa1e4 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -2071,6 +2071,12 @@ static int virtnet_rx_resize(struct virtnet_info *vi,
 	bool running = netif_running(vi->dev);
 	int err, qindex;
 
+	/* We cannot convert a ring to a small vring */
+	if (!vi->svring && IS_SMALL_VRING(ring_num)) {
+		netdev_err(vi->dev, "resize rx fail: size is too small..\n");
+		return -EINVAL;
+	}
+
 	qindex = rq - vi->rq;
 
 	if (running)
@@ -2097,6 +2103,12 @@ static int virtnet_tx_resize(struct virtnet_info *vi,
 
 	qindex = sq - vi->sq;
 
+	/* We cannot convert a ring to a small vring */
+	if (!vi->svring && IS_SMALL_VRING(ring_num)) {
+		netdev_err(vi->dev, "resize tx fail: size is too small..\n");
+		return -EINVAL;
+	}
+
 	if (running)
 		virtnet_napi_tx_disable(&sq->napi);
 
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ