[dpdk-stable] patch 'net/ena/base: prevent allocation of zero sized memory' has been queued to stable release 19.11.3

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue May 19 15:03:12 CEST 2020


Hi,

FYI, your patch has been queued to stable release 19.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/21/20. 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 c6730185e02a872b689027cb3faede52b48ab4d1 Mon Sep 17 00:00:00 2001
From: Igor Chauskin <igorch at amazon.com>
Date: Wed, 8 Apr 2020 10:28:54 +0200
Subject: [PATCH] net/ena/base: prevent allocation of zero sized memory

[ upstream commit 29dc10d9424ccf26a346387b0a707185e2432400 ]

rte_memzone_reserve() will reserve the biggest contiguous memzone
available if received 0 as size param.

Fixes: 9ba7981ec992 ("ena: add communication layer for DPDK")

Signed-off-by: Igor Chauskin <igorch at amazon.com>
Reviewed-by: Michal Krawczyk <mk at semihalf.com>
Reviewed-by: Guy Tzalik <gtzalik at amazon.com>
---
 drivers/net/ena/base/ena_plat_dpdk.h | 29 ++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index db9d1bb36b..dddfe65403 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -182,15 +182,18 @@ extern rte_atomic32_t ena_alloc_cnt;
 
 #define ENA_MEM_ALLOC_COHERENT(dmadev, size, virt, phys, handle)	\
 	do {								\
-		const struct rte_memzone *mz;				\
-		char z_name[RTE_MEMZONE_NAMESIZE];			\
+		const struct rte_memzone *mz = NULL;			\
 		ENA_TOUCH(dmadev); ENA_TOUCH(handle);			\
-		snprintf(z_name, sizeof(z_name),			\
+		if (size > 0) {						\
+			char z_name[RTE_MEMZONE_NAMESIZE];		\
+			snprintf(z_name, sizeof(z_name),		\
 			 "ena_alloc_%d",				\
 			 rte_atomic32_add_return(&ena_alloc_cnt, 1));	\
-		mz = rte_memzone_reserve(z_name, size, SOCKET_ID_ANY,	\
-				RTE_MEMZONE_IOVA_CONTIG);		\
-		handle = mz;						\
+			mz = rte_memzone_reserve(z_name, size,		\
+					SOCKET_ID_ANY,			\
+					RTE_MEMZONE_IOVA_CONTIG);	\
+			handle = mz;					\
+		}							\
 		if (mz == NULL) {					\
 			virt = NULL;					\
 			phys = 0;					\
@@ -208,15 +211,17 @@ extern rte_atomic32_t ena_alloc_cnt;
 #define ENA_MEM_ALLOC_COHERENT_NODE(					\
 	dmadev, size, virt, phys, mem_handle, node, dev_node)		\
 	do {								\
-		const struct rte_memzone *mz;				\
-		char z_name[RTE_MEMZONE_NAMESIZE];			\
+		const struct rte_memzone *mz = NULL;			\
 		ENA_TOUCH(dmadev); ENA_TOUCH(dev_node);			\
-		snprintf(z_name, sizeof(z_name),			\
+		if (size > 0) {						\
+			char z_name[RTE_MEMZONE_NAMESIZE];		\
+			snprintf(z_name, sizeof(z_name),		\
 			 "ena_alloc_%d",				\
-			 rte_atomic32_add_return(&ena_alloc_cnt, 1));	\
-		mz = rte_memzone_reserve(z_name, size, node,		\
+			 rte_atomic32_add_return(&ena_alloc_cnt, 1));   \
+			mz = rte_memzone_reserve(z_name, size, node,	\
 				RTE_MEMZONE_IOVA_CONTIG);		\
-		mem_handle = mz;					\
+			mem_handle = mz;				\
+		}							\
 		if (mz == NULL) {					\
 			virt = NULL;					\
 			phys = 0;					\
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-05-19 14:04:46.835489272 +0100
+++ 0057-net-ena-base-prevent-allocation-of-zero-sized-memory.patch	2020-05-19 14:04:44.204648155 +0100
@@ -1,13 +1,14 @@
-From 29dc10d9424ccf26a346387b0a707185e2432400 Mon Sep 17 00:00:00 2001
+From c6730185e02a872b689027cb3faede52b48ab4d1 Mon Sep 17 00:00:00 2001
 From: Igor Chauskin <igorch at amazon.com>
 Date: Wed, 8 Apr 2020 10:28:54 +0200
 Subject: [PATCH] net/ena/base: prevent allocation of zero sized memory
 
+[ upstream commit 29dc10d9424ccf26a346387b0a707185e2432400 ]
+
 rte_memzone_reserve() will reserve the biggest contiguous memzone
 available if received 0 as size param.
 
 Fixes: 9ba7981ec992 ("ena: add communication layer for DPDK")
-Cc: stable at dpdk.org
 
 Signed-off-by: Igor Chauskin <igorch at amazon.com>
 Reviewed-by: Michal Krawczyk <mk at semihalf.com>
@@ -17,10 +18,10 @@
  1 file changed, 17 insertions(+), 12 deletions(-)
 
 diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
-index 70261bdbc6..4b8fe017dd 100644
+index db9d1bb36b..dddfe65403 100644
 --- a/drivers/net/ena/base/ena_plat_dpdk.h
 +++ b/drivers/net/ena/base/ena_plat_dpdk.h
-@@ -184,15 +184,18 @@ extern rte_atomic32_t ena_alloc_cnt;
+@@ -182,15 +182,18 @@ extern rte_atomic32_t ena_alloc_cnt;
  
  #define ENA_MEM_ALLOC_COHERENT(dmadev, size, virt, phys, handle)	\
  	do {								\
@@ -45,7 +46,7 @@
  		if (mz == NULL) {					\
  			virt = NULL;					\
  			phys = 0;					\
-@@ -210,15 +213,17 @@ extern rte_atomic32_t ena_alloc_cnt;
+@@ -208,15 +211,17 @@ extern rte_atomic32_t ena_alloc_cnt;
  #define ENA_MEM_ALLOC_COHERENT_NODE(					\
  	dmadev, size, virt, phys, mem_handle, node, dev_node)		\
  	do {								\


More information about the stable mailing list