From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 819BE31FC; Fri, 23 Nov 2018 12:01:39 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D090236807; Fri, 23 Nov 2018 11:01:38 +0000 (UTC) Received: from [10.36.112.54] (ovpn-112-54.ams2.redhat.com [10.36.112.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3DB0B194AE; Fri, 23 Nov 2018 11:01:36 +0000 (UTC) To: Ferruh Yigit , dev@dpdk.org Cc: Thomas Monjalon , stable@dpdk.org, Stephen Hemminger References: <20181106214901.1392-2-stephen@networkplumber.org> <20181123002945.36697-1-ferruh.yigit@intel.com> From: Maxime Coquelin Message-ID: Date: Fri, 23 Nov 2018 12:01:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181123002945.36697-1-ferruh.yigit@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 23 Nov 2018 11:01:38 +0000 (UTC) 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2018 11:01:39 -0000 On 11/23/18 1:29 AM, Ferruh Yigit wrote: > 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)); > Reviewed-by: Maxime Coquelin Thanks, Maxime