From: Wenwu Ma <wenwux.ma@intel.com>
To: dev@dpdk.org
Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com,
jiayu.hu@intel.com, yvonnex.yang@intel.com,
Wenwu Ma <wenwux.ma@intel.com>
Subject: [dpdk-dev] [PATCH] examples/vhost: fix use-after-free on drain vhost
Date: Thu, 23 Sep 2021 20:29:46 +0000 [thread overview]
Message-ID: <20210923202946.23266-1-wenwux.ma@intel.com> (raw)
When a vdev is removed in destroy_device function,
the corresponding vhost_txbuff[vdev->vid] will also
be free, but the vhost_txbuff[vdev->vid] may still
be used in the drain_vhost function, which will cause
an error of heap-use-after-free. Therefore, before
accessing vhost_txbuff[vdev->vid], we need to check
whether the vdev has been removed, if so, let's skip
this vdev.
Signed-off-by: Wenwu Ma <wenwux.ma@intel.com>
---
examples/vhost/main.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index d0bf1f31e3..1f6f7be8e3 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -916,6 +916,9 @@ drain_vhost_table(void)
uint64_t cur_tsc;
TAILQ_FOREACH(vdev, &vhost_dev_list, global_vdev_entry) {
+ if (unlikely(vdev->remove == 1))
+ continue;
+
vhost_txq = vhost_txbuff[lcore_id * MAX_VHOST_DEVICE
+ vdev->vid];
--
2.25.1
next reply other threads:[~2021-09-23 8:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-23 20:29 Wenwu Ma [this message]
2021-09-24 2:22 ` Xia, Chenbo
2021-09-24 17:23 ` [dpdk-dev] [PATCH v2] " Wenwu Ma
2021-09-29 7:23 ` Xia, Chenbo
2021-10-21 12:28 ` Maxime Coquelin
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=20210923202946.23266-1-wenwux.ma@intel.com \
--to=wenwux.ma@intel.com \
--cc=chenbo.xia@intel.com \
--cc=dev@dpdk.org \
--cc=jiayu.hu@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=yvonnex.yang@intel.com \
/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).