[dpdk-stable] patch 'malloc: fix realloc copy size' has been queued to LTS release 17.11.10

luca.boccassi at gmail.com luca.boccassi at gmail.com
Thu Dec 19 15:34:30 CET 2019


Hi,

FYI, your patch has been queued to LTS release 17.11.10

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/21/19. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Thanks.

Luca Boccassi

---
>From 096199bcb05bb09fb180f71649968395a7c85509 Mon Sep 17 00:00:00 2001
From: Xueming Li <xuemingl at mellanox.com>
Date: Tue, 12 Nov 2019 14:50:27 +0000
Subject: [PATCH] malloc: fix realloc copy size

[ upstream commit a029a060369f74f42394301f87489aeb391220ef ]

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

Signed-off-by: Xueming Li <xuemingl at mellanox.com>
Reviewed-by: Anatoly Burakov <anatoly.burakov at intel.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 fe2278bcd7..1d3ab5ad73 100644
--- a/lib/librte_eal/common/rte_malloc.c
+++ b/lib/librte_eal/common/rte_malloc.c
@@ -177,7 +177,8 @@ rte_realloc(void *ptr, size_t size, unsigned align)
 	void *new_ptr = rte_malloc(NULL, size, align);
 	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.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-12-19 14:32:31.235523709 +0000
+++ 0123-malloc-fix-realloc-copy-size.patch	2019-12-19 14:32:26.325302188 +0000
@@ -1,14 +1,15 @@
-From a029a060369f74f42394301f87489aeb391220ef Mon Sep 17 00:00:00 2001
+From 096199bcb05bb09fb180f71649968395a7c85509 Mon Sep 17 00:00:00 2001
 From: Xueming Li <xuemingl at mellanox.com>
 Date: Tue, 12 Nov 2019 14:50:27 +0000
 Subject: [PATCH] malloc: fix realloc copy size
 
+[ upstream commit a029a060369f74f42394301f87489aeb391220ef ]
+
 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 at dpdk.org
 
 Signed-off-by: Xueming Li <xuemingl at mellanox.com>
 Reviewed-by: Anatoly Burakov <anatoly.burakov at intel.com>
@@ -17,11 +18,11 @@
  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
+index fe2278bcd7..1d3ab5ad73 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);
+@@ -177,7 +177,8 @@ rte_realloc(void *ptr, size_t size, unsigned align)
+ 	void *new_ptr = rte_malloc(NULL, size, align);
  	if (new_ptr == NULL)
  		return NULL;
 -	const unsigned old_size = elem->size - MALLOC_ELEM_OVERHEAD;


More information about the stable mailing list