* [PATCH 1/1] vhost: fix missing descriptor chains length checks
@ 2024-12-23 3:29 Yunjian Wang
0 siblings, 0 replies; only message in thread
From: Yunjian Wang @ 2024-12-23 3:29 UTC (permalink / raw)
To: dev
Cc: maxime.coquelin, chenbox, cheng1.jiang, jerry.lilijun,
Yunjian Wang, stable
The descriptor chains length must be greater than the Virtio-net
header size. Otherwise, such descriptor chains sizes implies no
packet data.
Fixes: fe8477ebbd94 ("vhost: support async packed ring dequeue")
Cc: stable@dpdk.org
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
lib/vhost/virtio_net.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index 69901ab3b5..8fc9bfa056 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -3962,6 +3962,16 @@ virtio_dev_tx_async_single_packed(struct virtio_net *dev,
VHOST_ACCESS_RO) < 0))
return -1;
+ if (unlikely(buf_len <= dev->vhost_hlen)) {
+ if (!allocerr_warned) {
+ VHOST_DATA_LOG(dev->ifname, ERR, "Invalid buffer length.");
+ allocerr_warned = true;
+ }
+ return -1;
+ }
+
+ buf_len -= dev->vhost_hlen;
+
if (unlikely(virtio_dev_pktmbuf_prep(dev, pkts, buf_len))) {
if (!allocerr_warned) {
VHOST_DATA_LOG(dev->ifname, ERR, "Failed mbuf alloc of size %d from %s.",
--
2.33.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-12-23 3:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-23 3:29 [PATCH 1/1] vhost: fix missing descriptor chains length checks Yunjian Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).