From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 2CFFC1B496; Fri, 23 Nov 2018 01:29:49 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Nov 2018 16:29:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,267,1539673200"; d="scan'208";a="93286366" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.212]) by orsmga006.jf.intel.com with ESMTP; 22 Nov 2018 16:29:47 -0800 From: Ferruh Yigit To: dev@dpdk.org Cc: Ferruh Yigit , Thomas Monjalon , stable@dpdk.org, Stephen Hemminger Date: Fri, 23 Nov 2018 00:29:45 +0000 Message-Id: <20181123002945.36697-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181106214901.1392-2-stephen@networkplumber.org> References: <20181106214901.1392-2-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH] bus/pci: fix allocation of PCI device path 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: Fri, 23 Nov 2018 00:29:50 -0000 The pci_resource_by_index called strlen() on uninitialized memory which would lead to the wrong size of memory allocated for the path portion of the resource map. This would either cause excessively large allocation, or worse memory corruption. Coverity Issue: 300868 Fixes: ea9d56226e72 ("pci: introduce function to map uio resource by index") Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger Signed-off-by: Ferruh Yigit --- drivers/bus/pci/linux/pci_uio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index a7c14421a..09ecbb7aa 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -296,7 +296,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, maps = uio_res->maps; /* allocate memory to keep path */ - maps[map_idx].path = rte_malloc(NULL, strlen(devname) + 1, 0); + maps[map_idx].path = rte_malloc(NULL, sizeof(devname), 0); if (maps[map_idx].path == NULL) { RTE_LOG(ERR, EAL, "Cannot allocate memory for path: %s\n", strerror(errno)); -- 2.17.2