DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>, dev@dpdk.org
Subject: Re: [dpdk-dev] [RFC 1/5] bus/pci: fix allocation of pci device path
Date: Thu, 22 Nov 2018 23:52:38 +0000	[thread overview]
Message-ID: <f0957bb0-f3c8-8de0-49af-1f57dcfa8c17@intel.com> (raw)
In-Reply-To: <20181106214901.1392-2-stephen@networkplumber.org>

On 11/6/2018 9:48 PM, Stephen Hemminger 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.

Yes this may corrupt memory, I wonder how nobody hit this. I am for including
the fix for the release.

> 
> Coverity Issue: 300868
> Fixes: ea9d56226e72 ("pci: introduce function to map uio resource by index")
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/bus/pci/linux/pci_uio.c | 29 ++++++++++++++---------------
>  1 file changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
> index a7c14421aa79..112ac51dddcc 100644
> --- a/drivers/bus/pci/linux/pci_uio.c
> +++ b/drivers/bus/pci/linux/pci_uio.c
> @@ -295,14 +295,6 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
>  	loc = &dev->addr;
>  	maps = uio_res->maps;
>  
> -	/* allocate memory to keep path */
> -	maps[map_idx].path = rte_malloc(NULL, strlen(devname) + 1, 0);
> -	if (maps[map_idx].path == NULL) {
> -		RTE_LOG(ERR, EAL, "Cannot allocate memory for path: %s\n",
> -				strerror(errno));
> -		return -1;
> -	}

What about simply:

-       maps[map_idx].path = rte_malloc(NULL, strlen(devname) + 1, 0);
+       maps[map_idx].path = rte_malloc(NULL, sizeof(devname) + 1, 0);

  parent reply	other threads:[~2018-11-22 23:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06 21:48 [dpdk-dev] [RFC 0/5] more Coverity related bug fixes Stephen Hemminger
2018-11-06 21:48 ` [dpdk-dev] [RFC 1/5] bus/pci: fix allocation of pci device path Stephen Hemminger
2018-11-18 15:03   ` Thomas Monjalon
2018-11-22 23:52   ` Ferruh Yigit [this message]
2018-11-23  0:29   ` [dpdk-dev] [PATCH] bus/pci: fix allocation of PCI " Ferruh Yigit
2018-11-23 10:45     ` Thomas Monjalon
2018-11-23 10:55       ` Andrew Rybchenko
2018-11-23 11:01     ` Maxime Coquelin
2018-11-25 10:53       ` Thomas Monjalon
2018-11-06 21:48 ` [dpdk-dev] [RFC 2/5] bus/pci: fix TOCTOU issue Stephen Hemminger
2018-11-18 15:04   ` Thomas Monjalon
2018-11-06 21:48 ` [dpdk-dev] [RFC 3/5] bpf: fix validation of eal_divmod Stephen Hemminger
2018-11-07 12:54   ` Ananyev, Konstantin
2018-11-07 19:51     ` Stephen Hemminger
2018-11-07 20:07       ` Ananyev, Konstantin
2018-11-07 23:04       ` Ananyev, Konstantin
2018-11-06 21:49 ` [dpdk-dev] [RFC 4/5] eal/memory: avoid double munmap in error path Stephen Hemminger
2018-11-06 23:10   ` Thomas Monjalon
2018-11-06 21:49 ` [dpdk-dev] [RFC 5/5] pipeline: remove dead code Stephen Hemminger
2018-11-18 15:07   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f0957bb0-f3c8-8de0-49af-1f57dcfa8c17@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).