patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Ajit Khaparde <ajit.khaparde@broadcom.com>
Cc: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>,
	dpdk stable <stable@dpdk.org>
Subject: patch 'net/bnxt: fix array overflow' has been queued to stable release 21.11.7
Date: Tue,  5 Mar 2024 15:34:31 +0000	[thread overview]
Message-ID: <20240305153449.263666-58-ktraynor@redhat.com> (raw)
In-Reply-To: <20240305153449.263666-1-ktraynor@redhat.com>

Hi,

FYI, your patch has been queued to stable release 21.11.7

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 03/11/24. 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.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/f6e82481277302959b2e0b05a73a61d5607ec240

Thanks.

Kevin

---
From f6e82481277302959b2e0b05a73a61d5607ec240 Mon Sep 17 00:00:00 2001
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
Date: Mon, 11 Dec 2023 09:11:03 -0800
Subject: [PATCH] net/bnxt: fix array overflow

[ upstream commit 4371b402c7bdbe821fff77e3c08e2faba67cb9b3 ]

In some cases the number of elements in the context memory array
can exceed the MAX_CTX_PAGES and that can cause the static members
ctx_pg_arr and ctx_dma_arr to overflow.
Allocate them dynamically to prevent this overflow.

Fixes: f8168ca0e690 ("net/bnxt: support thor controller")

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
---
 drivers/net/bnxt/bnxt.h        |  4 ++--
 drivers/net/bnxt/bnxt_ethdev.c | 42 +++++++++++++++++++++++++++-------
 2 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 76783eb3a1..31761f4804 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -442,6 +442,6 @@ struct bnxt_ring_mem_info {
 struct bnxt_ctx_pg_info {
 	uint32_t	entries;
-	void		*ctx_pg_arr[MAX_CTX_PAGES];
-	rte_iova_t	ctx_dma_arr[MAX_CTX_PAGES];
+	void		**ctx_pg_arr;
+	rte_iova_t	*ctx_dma_arr;
 	struct bnxt_ring_mem_info ring_mem;
 };
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 44fd45a4e9..55f96f0699 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -4691,5 +4691,5 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp,
 	struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem;
 	const struct rte_memzone *mz = NULL;
-	char mz_name[RTE_MEMZONE_NAMESIZE];
+	char name[RTE_MEMZONE_NAMESIZE];
 	rte_iova_t mz_phys_addr;
 	uint64_t valid_bits = 0;
@@ -4703,4 +4703,17 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp,
 			 BNXT_PAGE_SIZE;
 	rmem->page_size = BNXT_PAGE_SIZE;
+
+	snprintf(name, RTE_MEMZONE_NAMESIZE, "bnxt_ctx_pg_arr%s_%x_%d",
+		 suffix, idx, bp->eth_dev->data->port_id);
+	ctx_pg->ctx_pg_arr = rte_zmalloc(name, sizeof(void *) * rmem->nr_pages, 0);
+	if (ctx_pg->ctx_pg_arr == NULL)
+		return -ENOMEM;
+
+	snprintf(name, RTE_MEMZONE_NAMESIZE, "bnxt_ctx_dma_arr%s_%x_%d",
+		 suffix, idx, bp->eth_dev->data->port_id);
+	ctx_pg->ctx_dma_arr = rte_zmalloc(name, sizeof(rte_iova_t *) * rmem->nr_pages, 0);
+	if (ctx_pg->ctx_dma_arr == NULL)
+		return -ENOMEM;
+
 	rmem->pg_arr = ctx_pg->ctx_pg_arr;
 	rmem->dma_arr = ctx_pg->ctx_dma_arr;
@@ -4710,11 +4723,11 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp,
 
 	if (rmem->nr_pages > 1) {
-		snprintf(mz_name, RTE_MEMZONE_NAMESIZE,
+		snprintf(name, RTE_MEMZONE_NAMESIZE,
 			 "bnxt_ctx_pg_tbl%s_%x_%d",
 			 suffix, idx, bp->eth_dev->data->port_id);
-		mz_name[RTE_MEMZONE_NAMESIZE - 1] = 0;
-		mz = rte_memzone_lookup(mz_name);
+		name[RTE_MEMZONE_NAMESIZE - 1] = 0;
+		mz = rte_memzone_lookup(name);
 		if (!mz) {
-			mz = rte_memzone_reserve_aligned(mz_name,
+			mz = rte_memzone_reserve_aligned(name,
 						rmem->nr_pages * 8,
 						bp->eth_dev->device->numa_node,
@@ -4735,9 +4748,9 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp,
 	}
 
-	snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "bnxt_ctx_%s_%x_%d",
+	snprintf(name, RTE_MEMZONE_NAMESIZE, "bnxt_ctx_%s_%x_%d",
 		 suffix, idx, bp->eth_dev->data->port_id);
-	mz = rte_memzone_lookup(mz_name);
+	mz = rte_memzone_lookup(name);
 	if (!mz) {
-		mz = rte_memzone_reserve_aligned(mz_name,
+		mz = rte_memzone_reserve_aligned(name,
 						 mem_size,
 						 bp->eth_dev->device->numa_node,
@@ -4785,4 +4798,15 @@ static void bnxt_free_ctx_mem(struct bnxt *bp)
 
 	bp->ctx->flags &= ~BNXT_CTX_FLAG_INITED;
+	rte_free(bp->ctx->qp_mem.ctx_pg_arr);
+	rte_free(bp->ctx->srq_mem.ctx_pg_arr);
+	rte_free(bp->ctx->cq_mem.ctx_pg_arr);
+	rte_free(bp->ctx->vnic_mem.ctx_pg_arr);
+	rte_free(bp->ctx->stat_mem.ctx_pg_arr);
+	rte_free(bp->ctx->qp_mem.ctx_dma_arr);
+	rte_free(bp->ctx->srq_mem.ctx_dma_arr);
+	rte_free(bp->ctx->cq_mem.ctx_dma_arr);
+	rte_free(bp->ctx->vnic_mem.ctx_dma_arr);
+	rte_free(bp->ctx->stat_mem.ctx_dma_arr);
+
 	rte_memzone_free(bp->ctx->qp_mem.ring_mem.mz);
 	rte_memzone_free(bp->ctx->srq_mem.ring_mem.mz);
@@ -4797,4 +4821,6 @@ static void bnxt_free_ctx_mem(struct bnxt *bp)
 
 	for (i = 0; i < bp->ctx->tqm_fp_rings_count + 1; i++) {
+		rte_free(bp->ctx->tqm_mem[i]->ctx_pg_arr);
+		rte_free(bp->ctx->tqm_mem[i]->ctx_dma_arr);
 		if (bp->ctx->tqm_mem[i])
 			rte_memzone_free(bp->ctx->tqm_mem[i]->ring_mem.mz);
-- 
2.43.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-03-05 14:08:56.021503363 +0000
+++ 0058-net-bnxt-fix-array-overflow.patch	2024-03-05 14:08:54.706520913 +0000
@@ -1 +1 @@
-From 4371b402c7bdbe821fff77e3c08e2faba67cb9b3 Mon Sep 17 00:00:00 2001
+From f6e82481277302959b2e0b05a73a61d5607ec240 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 4371b402c7bdbe821fff77e3c08e2faba67cb9b3 ]
+
@@ -12 +13,0 @@
-Cc: stable@dpdk.org
@@ -22 +23 @@
-index 50f59552fa..dd08393b82 100644
+index 76783eb3a1..31761f4804 100644
@@ -25 +26 @@
-@@ -456,6 +456,6 @@ struct bnxt_ring_mem_info {
+@@ -442,6 +442,6 @@ struct bnxt_ring_mem_info {
@@ -35 +36 @@
-index b0589e2e49..762d863f14 100644
+index 44fd45a4e9..55f96f0699 100644
@@ -38 +39 @@
-@@ -4770,5 +4770,5 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp,
+@@ -4691,5 +4691,5 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp,
@@ -45 +46 @@
-@@ -4782,4 +4782,17 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp,
+@@ -4703,4 +4703,17 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp,
@@ -63 +64 @@
-@@ -4789,11 +4802,11 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp,
+@@ -4710,11 +4723,11 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp,
@@ -79 +80 @@
-@@ -4814,9 +4827,9 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp,
+@@ -4735,9 +4748,9 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp,
@@ -92 +93 @@
-@@ -4864,4 +4877,15 @@ static void bnxt_free_ctx_mem(struct bnxt *bp)
+@@ -4785,4 +4798,15 @@ static void bnxt_free_ctx_mem(struct bnxt *bp)
@@ -108 +109 @@
-@@ -4876,4 +4900,6 @@ static void bnxt_free_ctx_mem(struct bnxt *bp)
+@@ -4797,4 +4821,6 @@ static void bnxt_free_ctx_mem(struct bnxt *bp)


  parent reply	other threads:[~2024-03-05 15:36 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05 15:33 patch 'hash: remove some dead code' " Kevin Traynor
2024-03-05 15:33 ` patch 'regexdev: fix logtype register' " Kevin Traynor
2024-03-05 15:33 ` patch 'net/i40e: remove redundant judgment in flow parsing' " Kevin Traynor
2024-03-05 15:33 ` patch 'net/iavf: fix memory leak on security context error' " Kevin Traynor
2024-03-05 15:33 ` patch 'net/ixgbe: fix memoy leak after device init failure' " Kevin Traynor
2024-03-05 15:33 ` patch 'net/ice: fix link update' " Kevin Traynor
2024-03-05 15:33 ` patch 'net/ice: fix tunnel TSO capabilities' " Kevin Traynor
2024-03-05 15:33 ` patch 'kernel/freebsd: fix module build on FreeBSD 14' " Kevin Traynor
2024-03-05 15:33 ` patch 'ci: update versions of actions in GHA' " Kevin Traynor
2024-03-05 15:33 ` patch 'eal/x86: add AMD vendor check for TSC calibration' " Kevin Traynor
2024-03-05 15:33 ` patch 'eal: verify strdup return' " Kevin Traynor
2024-03-05 15:33 ` patch 'bus/dpaa: " Kevin Traynor
2024-03-05 15:33 ` patch 'bus/fslmc: " Kevin Traynor
2024-03-05 15:33 ` patch 'bus/vdev: " Kevin Traynor
2024-03-05 15:33 ` patch 'dma/idxd: " Kevin Traynor
2024-03-05 15:33 ` patch 'event/cnxk: " Kevin Traynor
2024-03-05 15:33 ` patch 'net/failsafe: fix memory leak in args parsing' " Kevin Traynor
2024-03-05 15:33 ` patch 'app/dumpcap: verify strdup return' " Kevin Traynor
2024-03-05 15:33 ` patch 'app/pdump: " Kevin Traynor
2024-03-05 15:33 ` patch 'app/crypto-perf: " Kevin Traynor
2024-03-05 15:33 ` patch 'test: " Kevin Traynor
2024-03-05 15:33 ` patch 'examples/qos_sched: fix memory leak in args parsing' " Kevin Traynor
2024-03-05 15:33 ` patch 'common/mlx5: fix calloc parameters' " Kevin Traynor
2024-03-05 15:33 ` patch 'net/bnx2x: " Kevin Traynor
2024-03-05 15:33 ` patch 'net/nfp: " Kevin Traynor
2024-03-05 15:33 ` patch 'build: fix linker warnings about undefined symbols' " Kevin Traynor
2024-03-05 15:34 ` patch 'vhost: fix virtqueue access check in vhost-user setup' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/virtio: remove duplicate queue xstats' " Kevin Traynor
2024-03-05 15:34 ` patch 'vhost: fix deadlock during vDPA SW live migration' " Kevin Traynor
2024-03-05 15:34 ` patch 'vhost: fix memory leak in Virtio Tx split path' " Kevin Traynor
2024-03-05 15:34 ` patch 'cryptodev: remove unused extern variable' " Kevin Traynor
2024-03-05 15:34 ` patch 'common/cnxk: fix memory leak in CPT init' " Kevin Traynor
2024-03-05 15:34 ` patch 'app/crypto-perf: fix next segment mbuf' " Kevin Traynor
2024-03-05 15:34 ` patch 'app/crypto-perf: fix data comparison' " Kevin Traynor
2024-03-05 15:34 ` patch 'app/crypto-perf: fix encrypt operation verification' " Kevin Traynor
2024-03-05 15:34 ` patch 'event/cnxk: fix dequeue timeout configuration' " Kevin Traynor
2024-03-05 15:34 ` patch 'test/event: skip test if no driver is present' " Kevin Traynor
2024-03-05 15:34 ` patch 'doc: fix commands in eventdev test tool guide' " Kevin Traynor
2024-03-05 15:34 ` patch 'ethdev: fix NVGRE encap flow action description' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/af_xdp: fix memzone leak on config failure' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/hns3: refactor VF mailbox message struct' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/hns3: refactor PF " Kevin Traynor
2024-03-05 15:34 ` patch 'net/hns3: fix VF multiple count on one reset' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/hns3: fix disable command with firmware' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/hns3: fix reset level comparison' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/hns3: remove QinQ insert support for VF' " Kevin Traynor
2024-03-05 15:34 ` patch 'doc: add --latencystats option in testpmd guide' " Kevin Traynor
2024-03-05 15:34 ` patch 'app/testpmd: hide --bitrate-stats in help if disabled' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/vmxnet3: fix initialization on FreeBSD' " Kevin Traynor
2024-03-05 15:34 ` patch 'drivers/net: fix buffer overflow for packet types list' " Kevin Traynor
2024-03-05 15:34 ` patch 'app/testpmd: fix crash in multi-process forwarding' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/ionic: fix RSS query' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/ionic: fix device close' " Kevin Traynor
2024-03-05 15:34 ` patch 'common/sfc_efx/base: use C11 static assert' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/memif: fix extra mbuf refcnt update in zero copy Tx' " Kevin Traynor
2024-03-05 15:34 ` patch 'net: add macros for VLAN metadata parsing' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/netvsc: fix " Kevin Traynor
2024-03-05 15:34 ` Kevin Traynor [this message]
2024-03-05 15:34 ` patch 'net/bnxt: fix 50G and 100G forced speed' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/bnxt: fix speed change from 200G to 25G on Thor' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/bnxt: fix backward firmware compatibility' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/bnxt: modify locking for representor Tx' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/bnxt: fix deadlock in ULP timer callback' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/cnxk: fix flow RSS configuration' " Kevin Traynor
2024-03-05 15:34 ` patch 'common/cnxk: fix mbox region copy' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/mlx5: fix jump action validation' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/mlx5: fix GENEVE TLV option management' " Kevin Traynor
2024-03-05 15:34 ` patch 'common/mlx5: fix duplicate read of general capabilities' " Kevin Traynor
2024-03-05 15:34 ` patch 'net/mlx5: fix stats query crash in secondary process' " Kevin Traynor
2024-03-05 15:34 ` patch 'telemetry: fix connected clients count' " Kevin Traynor
2024-03-05 15:34 ` patch 'telemetry: fix empty JSON dictionaries' " Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240305153449.263666-58-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=damodharam.ammepalli@broadcom.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).