From patchwork Sun Sep 24 16:19:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 29147 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8FB121B1FB; Sun, 24 Sep 2017 18:20:43 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id B72ED1B1F2; Sun, 24 Sep 2017 18:20:42 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13063356CD; Sun, 24 Sep 2017 16:20:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 13063356CD Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=maxime.coquelin@redhat.com Received: from localhost.localdomain (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAAA769FB8; Sun, 24 Sep 2017 16:20:38 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, remy.horton@intel.com, tiwei.bie@intel.com, yliu@fridaylinux.org Cc: mst@redhat.com, jfreiman@redhat.com, vkaplans@redhat.com, jasowang@redhat.com, Maxime Coquelin , stable@dpdk.org Date: Sun, 24 Sep 2017 18:19:16 +0200 Message-Id: <20170924161921.30010-15-maxime.coquelin@redhat.com> In-Reply-To: <20170924161921.30010-1-maxime.coquelin@redhat.com> References: <20170924161921.30010-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 24 Sep 2017 16:20:42 +0000 (UTC) Subject: [dpdk-dev] [PATCH v2 14/19] vhost: don't dereference invalid dev pointer after its reallocation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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. Cc: stable@dpdk.org Fixes: af295ad4698c ("vhost: realloc device and queues to same numa node as vring desc") Signed-off-by: Maxime Coquelin --- 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 8aca7ef7e..f495dd36e 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);