[dpdk-stable] patch 'vhost: fix dereferencing invalid pointer after realloc' has been queued to stable release 17.08.1

Yuanhan Liu yliu at fridaylinux.org
Tue Nov 21 14:17:11 CET 2017


Hi,

FYI, your patch has been queued to stable release 17.08.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/24/17. So please
shout if anyone has objections.

Thanks.

	--yliu

---
>From 5b94b247775e9de7849f2df088d407024f348210 Mon Sep 17 00:00:00 2001
From: Maxime Coquelin <maxime.coquelin at redhat.com>
Date: Thu, 5 Oct 2017 10:36:22 +0200
Subject: [PATCH] vhost: fix dereferencing invalid pointer after realloc

[ upstream commit b0098b5e2174bd4ac901043e1c4dcaad1c19d9d5 ]

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")

Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
Acked-by: Yuanhan Liu <yliu at fridaylinux.org>
---
 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 ad2e8d3..d8b84e2 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1102,6 +1102,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.7.4



More information about the stable mailing list