Skip to content

Commit

Permalink
vfio: fix use after free with multiprocess
Browse files Browse the repository at this point in the history
[ upstream commit d629884 ]

This patch fixes the heap-use-after-free bug which was found by ASAN
(Address-Sanitizer) in the vfio_get_default_container_fd function.

Fixes: 6bcb7c9 ("vfio: share default container in multi-process")

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  • Loading branch information
xavierhw authored and kevintraynor committed May 27, 2020
1 parent 7deb7d4 commit 8163def
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/librte_eal/linuxapp/eal/eal_vfio.c
Expand Up @@ -1025,6 +1025,7 @@ vfio_get_default_container_fd(void)
struct rte_mp_reply mp_reply = {0};
struct timespec ts = {.tv_sec = 5, .tv_nsec = 0};
struct vfio_mp_param *p = (struct vfio_mp_param *)mp_req.param;
int container_fd;

if (default_vfio_cfg->vfio_enabled)
return default_vfio_cfg->vfio_container_fd;
Expand All @@ -1047,8 +1048,9 @@ vfio_get_default_container_fd(void)
mp_rep = &mp_reply.msgs[0];
p = (struct vfio_mp_param *)mp_rep->param;
if (p->result == SOCKET_OK && mp_rep->num_fds == 1) {
container_fd = mp_rep->fds[0];
free(mp_reply.msgs);
return mp_rep->fds[0];
return container_fd;
}
}

Expand Down

0 comments on commit 8163def

Please sign in to comment.