[PATCH 2/3] eal/freebsd: Do not index out of bounds in memseg list

Jake Freeland jfree at FreeBSD.org
Tue May 6 19:50:08 CEST 2025


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 at 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



More information about the dev mailing list