DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] malloc: fix realloc wrong copy size
@ 2019-11-12 14:50 Xueming Li
  2019-11-12 14:50 ` [dpdk-dev] [PATCH 2/2] malloc: fix realloc padded element size Xueming Li
  2019-11-14 15:11 ` [dpdk-dev] [PATCH 1/2] malloc: fix realloc wrong copy size Burakov, Anatoly
  0 siblings, 2 replies; 12+ messages in thread
From: Xueming Li @ 2019-11-12 14:50 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: Asaf Penso, dev, stable

In rte_realloc, if the old element has pad and need to allocate a new
memory, the padding size was not deducted, so more data was copied to
new data area.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 lib/librte_eal/common/rte_malloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c
index 413e4aa004..d6026a2b17 100644
--- a/lib/librte_eal/common/rte_malloc.c
+++ b/lib/librte_eal/common/rte_malloc.c
@@ -150,7 +150,8 @@ rte_realloc_socket(void *ptr, size_t size, unsigned int align, int socket)
 	void *new_ptr = rte_malloc_socket(NULL, size, align, socket);
 	if (new_ptr == NULL)
 		return NULL;
-	const unsigned old_size = elem->size - MALLOC_ELEM_OVERHEAD;
+	/* elem: |pad|data_elem|data|trailer| */
+	const size_t old_size = elem->size - elem->pad - MALLOC_ELEM_OVERHEAD;
 	rte_memcpy(new_ptr, ptr, old_size < size ? old_size : size);
 	rte_free(ptr);
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-11-21 14:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-12 14:50 [dpdk-dev] [PATCH 1/2] malloc: fix realloc wrong copy size Xueming Li
2019-11-12 14:50 ` [dpdk-dev] [PATCH 2/2] malloc: fix realloc padded element size Xueming Li
2019-11-14 15:11   ` Burakov, Anatoly
2019-11-19 20:47   ` [dpdk-dev] [dpdk-stable] " David Marchand
2019-11-20  2:12     ` Xueming(Steven) Li
2019-11-20 13:25       ` David Marchand
2019-11-21 12:30         ` Burakov, Anatoly
2019-11-21 12:55           ` Xueming(Steven) Li
2019-11-21 13:15             ` Burakov, Anatoly
2019-11-21 13:17               ` Burakov, Anatoly
2019-11-21 14:11                 ` Xueming(Steven) Li
2019-11-14 15:11 ` [dpdk-dev] [PATCH 1/2] malloc: fix realloc wrong copy size Burakov, Anatoly

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).