From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <thomas@monjalon.net>
Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com
 [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 583071B4EA;
 Fri, 23 Nov 2018 11:45:50 +0100 (CET)
Received: from compute1.internal (compute1.nyi.internal [10.202.2.41])
 by mailout.nyi.internal (Postfix) with ESMTP id C817621FBA;
 Fri, 23 Nov 2018 05:45:48 -0500 (EST)
Received: from mailfrontend2 ([10.202.2.163])
 by compute1.internal (MEProxy); Fri, 23 Nov 2018 05:45:48 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h=
 from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding:content-type; s=mesmtp;
 bh=nWAHOmzXpAZcQSTfhu8tlDSf+eMZiyJOLDIEomP+YE0=; b=qZeWttfSHbtm
 n99I5ouNX/TJ1J11wWYmz1W1OoKN+GvYzZHC3b0sRT0BwtOHFDkrsQP011Vh+jNh
 kDj9uCvvx6IeRRT+SkCq9VOHmv+vuIw/fOl3ZbSw0/BLYwjW8N+fa1w7hVkFJ/AA
 dD3jvcDPZ+MWumI6oQbS/tx6EpNAuR0=
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-transfer-encoding:content-type
 :date:from:in-reply-to:message-id:mime-version:references
 :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender
 :x-sasl-enc; s=fm1; bh=nWAHOmzXpAZcQSTfhu8tlDSf+eMZiyJOLDIEomP+Y
 E0=; b=ZCJkm3J1BUIvDlnKBqGsPxJGye9E8oxk0MJrClC1gUEZFNaPJGuWTLiBa
 i/hCK19W4d0HFlf9ZR53vIQh7gR3udg4q6gmj6xaWQ99s3eKwOsmZ8TLOqfiMJ9N
 xWMOYGZFx+ELcAlPSN/6jESXaRV7pNo5EWJwu7Dfsyr9ViWTbliYLiksEyFheHyS
 DCL+dyplbwGQOKRPmXoEKL5uY7lEW68Pl/kP1Pus+zHxglh1/SjHgVvKveqJPQEl
 xzQCxBTjf8m1JDkhWGf6wwnmq/vaKDxv+jrOlgsY2Sur3IFB+CwZp9AayvO8TQbx
 HuHAWPOhtcCbXZ5eEukwRA9+TwNVA==
X-ME-Sender: <xms:XNr3WyiNhDsDK_MUrfY5D58SOV0dQmplSy-jKQAd-feJzQoT1fuZAQ>
X-ME-Proxy: <xmx:XNr3W39RnapW2uTQxjnzCO_CdkC4FxzGGG0x_kv6TPb173oOD0JOXg>
 <xmx:XNr3W0pLgHvLF_21a3BQb8vjvcwlEGpzpFF-MQQUgoHVT3-hnkCspw>
 <xmx:XNr3W1WQKUwha14NeLIi3NtEmGt9utEMjssD5LAGcjtuZ2wI6WQBOg>
 <xmx:XNr3Wx6cPDcTRcIZotfClGMJIL93Vi9uTaKLtNOtuslAXhYsFIqNFw>
 <xmx:XNr3WzAPr6LiuN6IZVQEVjE_PJkdezmhqNoUlK76lHEiOPcmE0V4GA>
 <xmx:XNr3W7K4JT_t5zjEDpzmqHDtjGu9YnrhhGUPJ7wReBbdA2QniAeqoQ>
Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184])
 by mail.messagingengine.com (Postfix) with ESMTPA id 4CF08102EA;
 Fri, 23 Nov 2018 05:45:47 -0500 (EST)
From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: Ferruh Yigit <ferruh.yigit@intel.com>, stable@dpdk.org,
 Stephen Hemminger <stephen@networkplumber.org>, gaetan.rivet@6wind.com,
 arybchenko@solarflare.com
Date: Fri, 23 Nov 2018 11:45:44 +0100
Message-ID: <1550603.EXdslK9Pks@xps>
In-Reply-To: <20181123002945.36697-1-ferruh.yigit@intel.com>
References: <20181106214901.1392-2-stephen@networkplumber.org>
 <20181123002945.36697-1-ferruh.yigit@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
Subject: Re: [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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Fri, 23 Nov 2018 10:45:50 -0000

Please, anyone for a review and a test?

23/11/2018 01:29, Ferruh Yigit:
> 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 <stephen@networkplumber.org>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
>  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));
>