DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jake Freeland <jfree@FreeBSD.org>
To: Anatoly Burakov <anatoly.burakov@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>
Cc: Jake Freeland <jfree@FreeBSD.org>, dev@dpdk.org
Subject: [PATCH 2/3] eal/freebsd: Do not index out of bounds in memseg list
Date: Tue,  6 May 2025 12:50:08 -0500	[thread overview]
Message-ID: <20250506175010.1141585-3-jfree@FreeBSD.org> (raw)
In-Reply-To: <20250506175010.1141585-1-jfree@FreeBSD.org>

It is possible for rte_fbarray_find_next_n_free() to misreport that there
are n contiguous open spots. If we need two contiguous entries for a
hole, make sure that we're not indexing out-of-bounds in the fbarray.

The `arr->len - arr->count < n` condition in fbarray_find_n() is meant to
safeguard against this, but we are not updating arr->count when inserting
holes, so an undesired index may be returned.

Signed-off-by: Jake Freeland <jfree@FreeBSD.org>
---
 lib/eal/freebsd/eal_memory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/eal/freebsd/eal_memory.c b/lib/eal/freebsd/eal_memory.c
index bcf5a6f986..bdbac0c3f3 100644
--- a/lib/eal/freebsd/eal_memory.c
+++ b/lib/eal/freebsd/eal_memory.c
@@ -171,6 +171,9 @@ rte_eal_hugepage_init(void)
 				    rte_fbarray_is_used(arr, ms_idx - 1))
 					ms_idx++;
 
+				if (ms_idx == (int)arr->len)
+					continue;
+
 				break;
 			}
 			if (msl_idx == RTE_MAX_MEMSEG_LISTS) {
-- 
2.47.2


  parent reply	other threads:[~2025-05-06 17:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06 17:50 [PATCH 0/3] EAL memory fixes Jake Freeland
2025-05-06 17:50 ` [PATCH 1/3] eal/freebsd: Do not use prev_ms_idx for hole detection Jake Freeland
2025-05-08 10:31   ` Burakov, Anatoly
2025-05-08 11:05   ` Burakov, Anatoly
2025-05-06 17:50 ` Jake Freeland [this message]
2025-05-08 11:20   ` [PATCH 2/3] eal/freebsd: Do not index out of bounds in memseg list Burakov, Anatoly
2025-05-06 17:50 ` [PATCH 3/3] eal/linux: Check hugepage access permissions Jake Freeland
2025-05-07  8:52   ` Stephen Hemminger
2025-05-07 16:09     ` Jake Freeland

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=20250506175010.1141585-3-jfree@FreeBSD.org \
    --to=jfree@freebsd.org \
    --cc=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@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).