DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jens Freimann <jfreiman@redhat.com>
To: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v2 1/3] vhost: fix malloc in rte_vhost_get_mem_table
Date: Thu, 11 May 2017 13:42:22 +0200	[thread overview]
Message-ID: <20170511114222.y7r2ifehoxej3iu5@dhcp-192-218.str.redhat.com> (raw)
In-Reply-To: <1494500208-78788-1-git-send-email-dariuszx.stojaczyk@intel.com>

On Thu, May 11, 2017 at 12:56:46PM +0200, Dariusz Stojaczyk wrote:
> Amount of allocated memory was too small, causing buffer overflow.
> 
> Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
> ---
> Removed Gerrit Change-Id
>  lib/librte_vhost/vhost.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
> index 0b19d2e..1f565fb 100644
> --- a/lib/librte_vhost/vhost.c
> +++ b/lib/librte_vhost/vhost.c
> @@ -369,7 +369,7 @@ rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem)
>  		return -1;
>  
>  	size = dev->mem->nregions * sizeof(struct rte_vhost_mem_region);
> -	m = malloc(size);
> +	m = malloc(sizeof(struct rte_vhost_memory) + size);

Why not just add it to the line above where size is calculated?
With that changed,

Reviewed-by: Jens Freimann <jfreimann@redhat.com> 


regards,
Jens

  parent reply	other threads:[~2017-05-11 11:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-11 10:23 [dpdk-dev] [PATCH " Dariusz Stojaczyk
2017-05-11 10:23 ` [dpdk-dev] [PATCH 2/3] vhost: free virtio_net::guest_pages in vhost_backend_cleanup() Dariusz Stojaczyk
2017-05-11 10:23 ` [dpdk-dev] [PATCH 3/3] vhost: access VhostUsrMsg via packed struct Dariusz Stojaczyk
2017-05-11 10:56 ` [dpdk-dev] [PATCH v2 1/3] vhost: fix malloc in rte_vhost_get_mem_table Dariusz Stojaczyk
2017-05-11 10:56   ` [dpdk-dev] [PATCH v2 2/3] vhost: free virtio_net::guest_pages in vhost_backend_cleanup() Dariusz Stojaczyk
2017-05-11 10:56   ` [dpdk-dev] [PATCH v2 3/3] vhost: access VhostUsrMsg via packed struct Dariusz Stojaczyk
2017-05-11 11:42   ` Jens Freimann [this message]
2017-05-11 12:32     ` [dpdk-dev] [PATCH v2 1/3] vhost: fix malloc in rte_vhost_get_mem_table Stojaczyk, DariuszX
2017-05-11 14:33   ` [dpdk-dev] [PATCH v3 0/3] vhost undefined behavior fixes Dariusz Stojaczyk
2017-05-11 14:33     ` [dpdk-dev] [PATCH v3 1/3] vhost: fix malloc in rte_vhost_get_mem_table() Dariusz Stojaczyk
2017-05-11 13:56       ` Jens Freimann
2017-05-11 14:33     ` [dpdk-dev] [PATCH v3 2/3] vhost: free guest_pages in vhost_backend_cleanup() Dariusz Stojaczyk
2017-05-11 14:31       ` Jens Freimann
2017-05-11 14:33     ` [dpdk-dev] [PATCH v3 3/3] vhost: access VhostUsrMsg via packed struct Dariusz Stojaczyk
2017-05-22  7:01       ` Yuanhan Liu
2017-05-24 13:12         ` Stojaczyk, DariuszX
2017-05-26  5:58           ` Yuanhan Liu
2017-05-26 11:59     ` [dpdk-dev] [PATCH v4 0/3] vhost: undefined behavior fixes Dariusz Stojaczyk
2017-05-26  8:40       ` Yuanhan Liu
2017-05-26 11:59       ` [dpdk-dev] [PATCH v4 1/3] vhost: fix malloc in rte_vhost_get_mem_table() Dariusz Stojaczyk
2017-05-26 11:59       ` [dpdk-dev] [PATCH v4 2/3] vhost: free guest_pages in vhost_backend_cleanup() Dariusz Stojaczyk
2017-05-26 11:59       ` [dpdk-dev] [PATCH v4 3/3] vhost: access VhostUsrMsg via packed struct Dariusz Stojaczyk

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=20170511114222.y7r2ifehoxej3iu5@dhcp-192-218.str.redhat.com \
    --to=jfreiman@redhat.com \
    --cc=dariuszx.stojaczyk@intel.com \
    --cc=dev@dpdk.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).