From b0098b5e2174bd4ac901043e1c4dcaad1c19d9d5 Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Thu, 5 Oct 2017 10:36:22 +0200 Subject: [PATCH] vhost: fix dereferencing invalid pointer after realloc numa_realloc() reallocates the virtio_net device structure and updates the vhost_devices[] table with the new pointer if the rings are allocated different NUMA node. Problem is that vhost_user_msg_handler() still dereferences old pointer afterward. This patch prevents this by fetching again the dev pointer in vhost_devices[] after messages have been handled. Fixes: af295ad4698c ("vhost: realloc device and queues to same numa node as vring desc") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin Acked-by: Yuanhan Liu --- lib/librte_vhost/vhost_user.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 3b934a7fa1..34086a764d 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1198,6 +1198,12 @@ vhost_user_msg_handler(int vid, int fd) } + /* + * The virtio_net struct might have been reallocated on a different + * NUMA node, so dev pointer might no more be valid. + */ + dev = get_device(vid); + if (msg.flags & VHOST_USER_NEED_REPLY) { msg.payload.u64 = !!ret; msg.size = sizeof(msg.payload.u64); -- 2.20.1