vhost: fix malloc size too small
authorDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Fri, 26 May 2017 11:59:13 +0000 (13:59 +0200)
committerYuanhan Liu <yliu@fridaylinux.org>
Fri, 16 Jun 2017 12:04:25 +0000 (14:04 +0200)
Amount of allocated memory was too small, causing buffer overflow.

Fixes: eb32247457fe ("vhost: export guest memory regions")
Cc: stable@dpdk.org
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jens Freimann <jfreiman@redhat.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
lib/librte_vhost/vhost.c

index 1b8e6bd..19c5a43 100644 (file)
@@ -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);
        if (!m)
                return -1;