From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 72E301396; Thu, 16 Mar 2017 17:28:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489681708; x=1521217708; h=from:to:cc:subject:date:message-id; bh=OZXsDjwnNk0k6jjR/qaWYX+9GpmOtLOYjaVct6TDN6w=; b=Smo1GR5wVH03+2krUm8LM9xxDTEzxW0C+80nO0Trfm0mSBgc+umb2Lmo ufV+on3irnegBeHw7D2Tqs3tY2v+EQ==; Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Mar 2017 09:28:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,173,1486454400"; d="scan'208";a="1109241489" Received: from dpdk06.sh.intel.com ([10.239.129.195]) by orsmga001.jf.intel.com with ESMTP; 16 Mar 2017 09:27:58 -0700 From: Jianfeng Tan To: dev@dpdk.org Cc: sergio.gonzalez.monroy@intel.com, benjamin.walker@intel.com, Jianfeng Tan , stable@dpdk.org Date: Thu, 16 Mar 2017 16:28:44 +0000 Message-Id: <1489681724-22114-1-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] eal/linux: fix multi-process cannot work 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: , X-List-Received-Date: Thu, 16 Mar 2017 16:28:29 -0000 When binding with vfio-pci, secondary process cannot be started with an error message: cannot find TAILQ entry for PCI device. It's due to: struct rte_pci_addr is padded with 1 byte for alignment by compiler. Then below comparison in commit 2f4adfad0a69 ("vfio: add multiprocess support") will fail if the last byte is not initialized. memcmp(&vfio_res->pci_addr, &dev->addr, sizeof(dev->addr) And commit cdc242f260e7 ("eal/linux: support running as unprivileged user") just triggers this bug by using a stack un-initialized variable. The fix is to use rte_eal_compare_pci_addr() for pci addr comparison. Fixes: 2f4adfad0a69 ("vfio: add multiprocess support") Fixes: cdc242f260e7 ("eal/linux: support running as unprivileged user") CC: stable@dpdk.org Reported-by: Rutkowski, Pawel Signed-off-by: Jianfeng Tan --- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c index 5f478c5..7d8b9fb 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c @@ -355,7 +355,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev) } else { /* if we're in a secondary process, just find our tailq entry */ TAILQ_FOREACH(vfio_res, vfio_res_list, next) { - if (memcmp(&vfio_res->pci_addr, &dev->addr, sizeof(dev->addr))) + if (rte_eal_compare_pci_addr(&vfio_res->pci_addr, + &dev->addr)) continue; break; } -- 2.7.4