public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: Yehor Malikov <malikovyehor@gmail.com>
To: dev@dpdk.org
Cc: maxime.coquelin@redhat.com, david.marchand@redhat.com,
	chenbox@nvidia.com, stephen@networkplumber.org,
	Yehor Malikov <Yehor.Malikov@solidigm.com>
Subject: [PATCH v12] vhost: fix use-after-free in fdset during shutdown
Date: Wed, 18 Feb 2026 10:05:40 +0100	[thread overview]
Message-ID: <20260218090540.89215-1-malikovyehor@gmail.com> (raw)
In-Reply-To: <CAJFAV8yjTs8inmZqYyPrTubc_oaKfEi=nv_58HzyXf9f+pPg0Q@mail.gmail.com>

From: Yehor Malikov <Yehor.Malikov@solidigm.com>

The fdset_event_dispatch thread runs in a loop checking the destroy
flag after each epoll_wait iteration. During process exit,
rte_eal_cleanup() frees hugepage memory while the fdset thread is
still running. Since the fdset structure was allocated with
rte_zmalloc() (hugepage-backed), accessing it after rte_eal_cleanup()
causes use-after-free.

Switch fdset allocation from rte_zmalloc/rte_free to libc
calloc/free. The fdset is a control-path structure that does not
need hugepage memory. Using libc allocation ensures the fdset
remains valid after rte_eal_cleanup() releases hugepages.

Fixes: e68a6feaa3b3 ("vhost: improve fdset initialization")

Signed-off-by: Yehor Malikov <Yehor.Malikov@solidigm.com>
---
 .mailmap           | 1 +
 lib/vhost/fd_man.c | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/.mailmap b/.mailmap
index fc53ed2a55..711a6ceff5 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1840,6 +1840,7 @@ Yaroslav Brustinov <ybrustin@cisco.com>
 Yash Sharma <ysharma@marvell.com>
 Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp> <yasufum.o@gmail.com>
 Yelena Krivosheev <yelena@marvell.com>
+Yehor Malikov <Yehor.Malikov@solidigm.com>
 Yerden Zhumabekov <e_zhumabekov@sts.kz> <yerden.zhumabekov@sts.kz>
 Yevgeny Kliteynik <kliteyn@nvidia.com>
 Yi Chen <chenyi221@huawei.com>
diff --git a/lib/vhost/fd_man.c b/lib/vhost/fd_man.c
index f9147edee7..5748bc31e2 100644
--- a/lib/vhost/fd_man.c
+++ b/lib/vhost/fd_man.c
@@ -4,13 +4,13 @@
 
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <sys/epoll.h>
 #include <unistd.h>
 
 #include <rte_common.h>
 #include <rte_log.h>
-#include <rte_malloc.h>
 #include <rte_string_fns.h>
 #include <rte_thread.h>
 
@@ -94,7 +94,7 @@ fdset_init(const char *name)
 		return fdset;
 	}
 
-	fdset = rte_zmalloc(NULL, sizeof(*fdset), 0);
+	fdset = calloc(1, sizeof(*fdset));
 	if (!fdset) {
 		VHOST_FDMAN_LOG(ERR, "failed to alloc fdset %s", name);
 		goto err_unlock;
@@ -142,7 +142,7 @@ fdset_init(const char *name)
 err_epoll:
 	close(fdset->epfd);
 err_free:
-	rte_free(fdset);
+	free(fdset);
 err_unlock:
 	pthread_mutex_unlock(&fdsets_mutex);
 
-- 
2.52.0


  reply	other threads:[~2026-02-18  9:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-04 18:03 [PATCH] vhost: fix use-after-free in fdset during shutdown Yehor Malikov
2026-02-04 18:48 ` [PATCH v2] " malikovyehor
2026-02-04 18:58   ` [PATCH v3] " Yehor Malikov
2026-02-04 20:34     ` Stephen Hemminger
2026-02-04 21:32     ` Yehor Malikov
2026-02-04 21:35     ` [PATCH v4] " Yehor Malikov
2026-02-04 22:00       ` [PATCH v5] " Yehor Malikov
2026-02-04 23:05         ` [PATCH v6] " Yehor Malikov
2026-02-05  1:17           ` Stephen Hemminger
2026-02-05 11:16           ` [PATCH v7] " Yehor Malikov
2026-02-05 11:20           ` Yehor Malikov
2026-02-05 18:30             ` [PATCH v8] " Yehor Malikov
2026-02-05 18:35               ` [PATCH v9] " Yehor Malikov
2026-02-16 10:17                 ` Yehor Malikov
2026-02-17 14:31                 ` David Marchand
2026-02-18  7:50                   ` [PATCH v10] " Yehor Malikov
2026-02-18  8:01                     ` [PATCH v11] " Yehor Malikov
2026-02-18  8:52                       ` David Marchand
2026-02-18  9:05                         ` Yehor Malikov [this message]
2026-02-18 10:27                           ` [PATCH v12] " David Marchand
2026-02-27  9:00                             ` fengchengwen
2026-03-05 10:50                           ` Maxime Coquelin
2026-03-05 13:52                             ` 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=20260218090540.89215-1-malikovyehor@gmail.com \
    --to=malikovyehor@gmail.com \
    --cc=Yehor.Malikov@solidigm.com \
    --cc=chenbox@nvidia.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=stephen@networkplumber.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