DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v2 0/1] net/ena/base: bug fix for 23.11 stable only
@ 2024-04-08 12:15 shaibran
  2024-04-08 12:15 ` [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumption shaibran
  0 siblings, 1 reply; 4+ messages in thread
From: shaibran @ 2024-04-08 12:15 UTC (permalink / raw)
  To: ferruh.yigit, bluca, christian.ehrhardt, xuemingl, ktraynor
  Cc: stable, dev, Shai Brandes

From: Shai Brandes <shaibran@amazon.com>

Hi, the fix is for a bug that was introduced in 23.11.

The fix was already merged into 24.03 indirectly as part of c8a1898f82f8 ("net/ena: improve style and readability")
and the entire function was later restructured in patch bcb1753156ac ("net/ena/base: modify customer metrics memory management").

Meaning, this issue is indirectly fixed going forward, but we need to introduce a dedicated fix for 23.11 stable only.
I CC'ed also dev mailing list since this involves Bugzilla bug fix.

All the best,
Shai

---
v2:
* reordered the tags in the commit message

Shai Brandes (1):
  net/ena/base: fix metrics excessive memory consumption

 drivers/net/ena/base/ena_com.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

-- 
2.17.1


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

* [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumption
  2024-04-08 12:15 [PATCH v2 0/1] net/ena/base: bug fix for 23.11 stable only shaibran
@ 2024-04-08 12:15 ` shaibran
  2024-04-13  8:23   ` Xueming Li
  0 siblings, 1 reply; 4+ messages in thread
From: shaibran @ 2024-04-08 12:15 UTC (permalink / raw)
  To: ferruh.yigit, bluca, christian.ehrhardt, xuemingl, ktraynor
  Cc: stable, dev, Shai Brandes

From: Shai Brandes <shaibran@amazon.com>

[ upstream commit c8a1898f82f8c04cbe1d3e2d0eec0705386c23f7 ]

The driver accidentally allocates a huge memory
buffer for the customer metrics because it uses
an uninitialized variable for the buffer length.
This can lead to excessive memory footprint for
the driver which can even fail to initialize in
case of insufficient memory.

Bugzilla ID: 1400
Fixes: f73f53f7dc7a ("net/ena: upgrade HAL")
Cc: stable@dpdk.org

Signed-off-by: Shai Brandes <shaibran@amazon.com>
Reviewed-by: Amit Bernstein <amitbern@amazon.com>
---
 drivers/net/ena/base/ena_com.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ena/base/ena_com.c b/drivers/net/ena/base/ena_com.c
index 6953a1fa33..8ae7dcf48e 100644
--- a/drivers/net/ena/base/ena_com.c
+++ b/drivers/net/ena/base/ena_com.c
@@ -3134,16 +3134,18 @@ int ena_com_allocate_debug_area(struct ena_com_dev *ena_dev,
 int ena_com_allocate_customer_metrics_buffer(struct ena_com_dev *ena_dev)
 {
 	struct ena_customer_metrics *customer_metrics = &ena_dev->customer_metrics;
+	customer_metrics->buffer_len = ENA_CUSTOMER_METRICS_BUFFER_SIZE;
+	customer_metrics->buffer_virt_addr = NULL;
 
 	ENA_MEM_ALLOC_COHERENT(ena_dev->dmadev,
 			       customer_metrics->buffer_len,
 			       customer_metrics->buffer_virt_addr,
 			       customer_metrics->buffer_dma_addr,
 			       customer_metrics->buffer_dma_handle);
-	if (unlikely(customer_metrics->buffer_virt_addr == NULL))
+	if (unlikely(customer_metrics->buffer_virt_addr == NULL)) {
+		customer_metrics->buffer_len = 0;
 		return ENA_COM_NO_MEM;
-
-	customer_metrics->buffer_len = ENA_CUSTOMER_METRICS_BUFFER_SIZE;
+	}
 
 	return 0;
 }
-- 
2.17.1


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

* Re: [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumption
  2024-04-08 12:15 ` [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumption shaibran
@ 2024-04-13  8:23   ` Xueming Li
  0 siblings, 0 replies; 4+ messages in thread
From: Xueming Li @ 2024-04-13  8:23 UTC (permalink / raw)
  To: shaibran, ferruh.yigit, bluca, christian.ehrhardt, ktraynor; +Cc: stable, dev

[-- Attachment #1: Type: text/plain, Size: 2548 bytes --]

Hi Shai,

Thanks for the backporting, patch queued to 23.11.1 staging branch.

________________________________
From: shaibran@amazon.com <shaibran@amazon.com>
Sent: Monday, April 8, 2024 8:15 PM
To: ferruh.yigit@amd.com <ferruh.yigit@amd.com>; bluca@debian.org <bluca@debian.org>; christian.ehrhardt@canonical.com <christian.ehrhardt@canonical.com>; Xueming Li <xuemingl@nvidia.com>; ktraynor@redhat.com <ktraynor@redhat.com>
Cc: stable@dpdk.org <stable@dpdk.org>; dev@dpdk.org <dev@dpdk.org>; Shai Brandes <shaibran@amazon.com>
Subject: [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumption

From: Shai Brandes <shaibran@amazon.com>

[ upstream commit c8a1898f82f8c04cbe1d3e2d0eec0705386c23f7 ]

The driver accidentally allocates a huge memory
buffer for the customer metrics because it uses
an uninitialized variable for the buffer length.
This can lead to excessive memory footprint for
the driver which can even fail to initialize in
case of insufficient memory.

Bugzilla ID: 1400
Fixes: f73f53f7dc7a ("net/ena: upgrade HAL")
Cc: stable@dpdk.org

Signed-off-by: Shai Brandes <shaibran@amazon.com>
Reviewed-by: Amit Bernstein <amitbern@amazon.com>
---
 drivers/net/ena/base/ena_com.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ena/base/ena_com.c b/drivers/net/ena/base/ena_com.c
index 6953a1fa33..8ae7dcf48e 100644
--- a/drivers/net/ena/base/ena_com.c
+++ b/drivers/net/ena/base/ena_com.c
@@ -3134,16 +3134,18 @@ int ena_com_allocate_debug_area(struct ena_com_dev *ena_dev,
 int ena_com_allocate_customer_metrics_buffer(struct ena_com_dev *ena_dev)
 {
         struct ena_customer_metrics *customer_metrics = &ena_dev->customer_metrics;
+       customer_metrics->buffer_len = ENA_CUSTOMER_METRICS_BUFFER_SIZE;
+       customer_metrics->buffer_virt_addr = NULL;

         ENA_MEM_ALLOC_COHERENT(ena_dev->dmadev,
                                customer_metrics->buffer_len,
                                customer_metrics->buffer_virt_addr,
                                customer_metrics->buffer_dma_addr,
                                customer_metrics->buffer_dma_handle);
-       if (unlikely(customer_metrics->buffer_virt_addr == NULL))
+       if (unlikely(customer_metrics->buffer_virt_addr == NULL)) {
+               customer_metrics->buffer_len = 0;
                 return ENA_COM_NO_MEM;
-
-       customer_metrics->buffer_len = ENA_CUSTOMER_METRICS_BUFFER_SIZE;
+       }

         return 0;
 }
--
2.17.1


[-- Attachment #2: Type: text/html, Size: 5284 bytes --]

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

* [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumption
  2024-03-28 14:03 [PATCH v2 0/1] net/ena/base: bug fix for 23.11 stable only shaibran
@ 2024-03-28 14:03 ` shaibran
  0 siblings, 0 replies; 4+ messages in thread
From: shaibran @ 2024-03-28 14:03 UTC (permalink / raw)
  To: ferruh.yigit, bluca, christian.ehrhardt, xuemingl, ktraynor
  Cc: stable, dev, Shai Brandes

From: Shai Brandes <shaibran@amazon.com>

The driver accidentally allocates a huge memory
buffer for the customer metrics because it uses
an uninitialized variable for the buffer length.
This can lead to excessive memory footprint for
the driver which can even fail to initialize in
case of insufficient memory.

Signed-off-by: Shai Brandes <shaibran@amazon.com>
Reviewed-by: Amit Bernstein <amitbern@amazon.com>
Fixes: f73f53f7dc7a ("net/ena: upgrade HAL")
Bugzilla ID: 1400
---
 drivers/net/ena/base/ena_com.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ena/base/ena_com.c b/drivers/net/ena/base/ena_com.c
index 6953a1fa33..8ae7dcf48e 100644
--- a/drivers/net/ena/base/ena_com.c
+++ b/drivers/net/ena/base/ena_com.c
@@ -3134,16 +3134,18 @@ int ena_com_allocate_debug_area(struct ena_com_dev *ena_dev,
 int ena_com_allocate_customer_metrics_buffer(struct ena_com_dev *ena_dev)
 {
 	struct ena_customer_metrics *customer_metrics = &ena_dev->customer_metrics;
+	customer_metrics->buffer_len = ENA_CUSTOMER_METRICS_BUFFER_SIZE;
+	customer_metrics->buffer_virt_addr = NULL;
 
 	ENA_MEM_ALLOC_COHERENT(ena_dev->dmadev,
 			       customer_metrics->buffer_len,
 			       customer_metrics->buffer_virt_addr,
 			       customer_metrics->buffer_dma_addr,
 			       customer_metrics->buffer_dma_handle);
-	if (unlikely(customer_metrics->buffer_virt_addr == NULL))
+	if (unlikely(customer_metrics->buffer_virt_addr == NULL)) {
+		customer_metrics->buffer_len = 0;
 		return ENA_COM_NO_MEM;
-
-	customer_metrics->buffer_len = ENA_CUSTOMER_METRICS_BUFFER_SIZE;
+	}
 
 	return 0;
 }
-- 
2.17.1


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

end of thread, other threads:[~2024-04-13  8:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-08 12:15 [PATCH v2 0/1] net/ena/base: bug fix for 23.11 stable only shaibran
2024-04-08 12:15 ` [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumption shaibran
2024-04-13  8:23   ` Xueming Li
  -- strict thread matches above, loose matches on Subject: below --
2024-03-28 14:03 [PATCH v2 0/1] net/ena/base: bug fix for 23.11 stable only shaibran
2024-03-28 14:03 ` [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumption shaibran

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