DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Manish Kurup <manish.kurup@broadcom.com>
To: dev@dpdk.org
Cc: kishore.padmanabha@broadcom.com,
	Joseph Wong <joseph.wong@broadcom.com>,
	stable@dpdk.org
Subject: [PATCH] net/bnxt: fix bit allocator out of bounds read
Date: Mon,  5 Oct 2026 15:25:15 -0500	[thread overview]
Message-ID: <20261005202515.17821-1-manish.kurup@broadcom.com> (raw)

From: Joseph Wong <joseph.wong@broadcom.com>

In ulp_bit_alloc_list_alloc(), the loop condition could allow the
index to reach bsize_64 before the bounds check ran (the do-while
body reads blist->bdata[idx++] before the loop condition tests
idx <= bsize_64), causing an out-of-bounds read one element past
the array. Refactor the loop to check the bound before indexing.

Fixes: 0001cc58d362 ("net/bnxt: support generic hash table")
Cc: stable@dpdk.org

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
Signed-off-by: Manish Kurup <manish.kurup@broadcom.com>
---
 .mailmap                               |  1 +
 drivers/net/bnxt/tf_ulp/ulp_gen_hash.c | 17 ++++++++---------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/.mailmap b/.mailmap
index 2e348c3bce..e013a7d6ba 100644
--- a/.mailmap
+++ b/.mailmap
@@ -813,6 +813,7 @@ Jonathan Tsai <jonathan1.tsai@intel.com>
 Joongi Kim <joongi@an.kaist.ac.kr>
 Jörg Thalheim <joerg@thalheim.io>
 Joseph Richard <joseph.richard@windriver.com>
+Joseph Wong <joseph.wong@broadcom.com>
 Josh Soref <jsoref@gmail.com>
 Joshua Hay <joshua.a.hay@intel.com>
 Joshua Washington <joshwash@google.com>
diff --git a/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c b/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c
index 74cdd5c1da..d94b59286f 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c
@@ -21,16 +21,15 @@ int32_t ulp_bit_alloc_list_alloc(struct bit_alloc_list *blist,
 	uint32_t bsize_64 = blist->bsize / ULP_64B_IN_BYTES;
 
 	/* Iterate all numbers that have all 1's */
-	do {
-		bentry = blist->bdata[idx++];
-	} while (bentry == -1UL && idx <= bsize_64);
-
-	if (idx <= bsize_64) {
-		if (bentry)
+	while (idx < bsize_64) {
+		bentry = blist->bdata[idx];
+		if (bentry != -1UL) {
 			jdx = rte_clz64(~bentry);
-		*index = ((idx - 1) * ULP_INDEX_BITMAP_SIZE) + jdx;
-		ULP_INDEX_BITMAP_SET(blist->bdata[(idx - 1)], jdx);
-		return 0;
+			*index = (idx * ULP_INDEX_BITMAP_SIZE) + jdx;
+			ULP_INDEX_BITMAP_SET(blist->bdata[idx], jdx);
+			return 0;
+		}
+		idx++;
 	}
 	jdx = (uint32_t)(bsize_64 * ULP_INDEX_BITMAP_SIZE);
 	BNXT_DRV_DBG(ERR, "bit allocator is full reached max:%d\n", jdx);
-- 
2.31.1


                 reply	other threads:[~2026-10-05 20:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261005202515.17821-1-manish.kurup@broadcom.com \
    --to=manish.kurup@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=joseph.wong@broadcom.com \
    --cc=kishore.padmanabha@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