From: Mike Cui <cuicui@gmail.com>
To: dev@dpdk.org, cheng1.jiang@intel.com
Subject: lib/vhost/virtio_net: possible stack overflow in virtio_dev_tx_async_packed()
Date: Wed, 28 Dec 2022 12:37:46 -0800 [thread overview]
Message-ID: <CAMbjb13eKiqThsRoE1yvrK9J55YDEk0F8PcXMUhoUnLZE=7_hQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 774 bytes --]
Hi,
I believe there is a possible stack overflow in this code:
https://github.com/DPDK/dpdk/blob/main/lib/vhost/virtio_net.c#L3631
Here, pkts_prealloc is declared on the stack with size MAX_PKT_BURST, then
filled in by rte_pktmbuf_alloc_bulk() up to 'count' elements, but 'count'
is not capped at MAX_PKT_BURST like in many other code paths.
Suggested patch:
diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index 9abf752f30..21f00317c7 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -3634,6 +3634,7 @@ virtio_dev_tx_async_packed(struct virtio_net *dev,
struct vhost_virtqueue *vq,
async_iter_reset(async);
+ count = RTE_MIN(count, MAX_PKT_BURST);
if (rte_pktmbuf_alloc_bulk(mbuf_pool, pkts_prealloc, count))
goto out;
[-- Attachment #2: Type: text/html, Size: 4947 bytes --]
next reply other threads:[~2023-01-02 9:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-28 20:37 Mike Cui [this message]
2023-01-29 2:11 ` Jiang, Cheng1
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMbjb13eKiqThsRoE1yvrK9J55YDEk0F8PcXMUhoUnLZE=7_hQ@mail.gmail.com' \
--to=cuicui@gmail.com \
--cc=cheng1.jiang@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).