[PATCH v13 12/17] eal: check tailq length

Stephen Hemminger
2026-01-27T16:34:29Z

The tailq name should not be allowed to exceed limits.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
doc/guides/rel_notes/release_26_03.rst | 1 +
lib/eal/common/eal_common_tailqs.c | 13 ++++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_26_03.rst b/doc/guides/rel_notes/release_26_03.rst
index 91b1808455..d643206167 100644
--- a/doc/guides/rel_notes/release_26_03.rst
+++ b/doc/guides/rel_notes/release_26_03.rst
@@ -93,6 +93,7 @@ API Changes
* lpm: name must be less than RTE_LPM_NAMESIZE.
* hash: name parameter must be less than RTE_HASH_NAMESIZE.
* efd: name must be less than RTE_EFD_NAMESIZE.
+ * tailq: name must be less than RTE_TAILQ_NAMESIZE.

ABI Changes
diff --git a/lib/eal/common/eal_common_tailqs.c b/lib/eal/common/eal_common_tailqs.c
index 47080d75ac..c581f43b6f 100644
--- a/lib/eal/common/eal_common_tailqs.c
+++ b/lib/eal/common/eal_common_tailqs.c
@@ -8,6 +8,7 @@

#include <rte_eal.h>
#include <rte_eal_memconfig.h>
+#include <rte_errno.h>
#include <rte_log.h>
#include <rte_string_fns.h>

@@ -30,8 +31,10 @@ rte_eal_tailq_lookup(const char *name)
unsigned i;
struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;

- if (name == NULL)
+ if (name == NULL) {
+ rte_errno = EINVAL;
return NULL;
+ }

for (i = 0; i < RTE_MAX_TAILQ; i++) {
if (!strncmp(name, mcfg->tailq_head[i].name,
@@ -39,6 +42,7 @@ rte_eal_tailq_lookup(const char *name)
return &mcfg->tailq_head[i];
}

+ rte_errno = ENOENT;
return NULL;
}

@@ -67,6 +71,12 @@ rte_eal_tailq_create(const char *name)
{
struct rte_tailq_head *head = NULL;

+ if (strlen(name) >= sizeof(head->name)) {
+ EAL_LOG(ERR, "tailq name '%s' is too long", name);
+ rte_errno = ENAMETOOLONG;
+ return NULL;
+ }
+
if (!rte_eal_tailq_lookup(name) &&
(rte_tailqs_count + 1 < RTE_MAX_TAILQ)) {
struct rte_mem_config *mcfg;
@@ -115,6 +125,7 @@ rte_eal_tailq_register(struct rte_tailq_elem *t)
if (rte_eal_tailq_local_register(t) < 0) {
EAL_LOG(ERR,
"%s tailq is already registered", t->name);
+ rte_errno = EEXIST;
goto error;
}

--
2.51.0