From: Long Li <longli@microsoft.com>
To: dev@dpdk.org
Cc: bruce.richardson@intel.com, stephen@networkplumber.org,
Long Li <longli@microsoft.com>
Subject: [PATCH 1/2] eal: return error on devargs truncation in hotplug MP messages
Date: Tue, 24 Mar 2026 18:45:05 -0700 [thread overview]
Message-ID: <20260325014506.1866374-1-longli@microsoft.com> (raw)
The EAL hotplug multi-process messaging uses a fixed-size buffer
(EAL_DEV_MP_DEV_ARGS_MAX_LEN, 128 bytes) for device arguments.
When devargs exceeds this limit, strlcpy silently truncates the
string. This causes secondary processes to receive incomplete
devargs during hotplug re-add, leading to failed port
re-initialization.
For example, a MANA PCI device with 6 mac= arguments:
mac=AA:BB:CC:DD:EE:01,mac=AA:BB:CC:DD:EE:02,
mac=AA:BB:CC:DD:EE:03,mac=AA:BB:CC:DD:EE:04,
mac=AA:BB:CC:DD:EE:05,mac=AA:BB:CC:DD:EE:06
produces a 131-byte devargs string that gets silently truncated
to 127 bytes, losing the last MAC address.
Return -E2BIG from rte_dev_probe() and rte_dev_remove() when
devargs would be truncated, instead of silently corrupting data.
Signed-off-by: Long Li <longli@microsoft.com>
---
lib/eal/common/eal_common_dev.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c
index 7185de0cb9..de24d14d28 100644
--- a/lib/eal/common/eal_common_dev.c
+++ b/lib/eal/common/eal_common_dev.c
@@ -250,6 +250,11 @@ rte_dev_probe(const char *devargs)
memset(&req, 0, sizeof(req));
req.t = EAL_DEV_REQ_TYPE_ATTACH;
+ if (strlen(devargs) >= EAL_DEV_MP_DEV_ARGS_MAX_LEN) {
+ EAL_LOG(ERR, "devargs truncated (len %zu, max %d)",
+ strlen(devargs), EAL_DEV_MP_DEV_ARGS_MAX_LEN);
+ return -E2BIG;
+ }
strlcpy(req.devargs, devargs, EAL_DEV_MP_DEV_ARGS_MAX_LEN);
if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
@@ -397,6 +402,12 @@ rte_dev_remove(struct rte_device *dev)
memset(&req, 0, sizeof(req));
req.t = EAL_DEV_REQ_TYPE_DETACH;
+ if (strlen(devargs) >= EAL_DEV_MP_DEV_ARGS_MAX_LEN) {
+ EAL_LOG(ERR, "devargs truncated (len %zu, max %d)",
+ strlen(devargs), EAL_DEV_MP_DEV_ARGS_MAX_LEN);
+ free(devargs);
+ return -E2BIG;
+ }
strlcpy(req.devargs, devargs, EAL_DEV_MP_DEV_ARGS_MAX_LEN);
free(devargs);
--
2.43.0
next reply other threads:[~2026-03-25 1:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 1:45 Long Li [this message]
2026-03-25 1:45 ` [PATCH 2/2] eal: add meson options for hotplug MP message buffer sizes Long Li
2026-03-25 2:44 ` Stephen Hemminger
2026-03-25 18:42 ` [EXTERNAL] " Long Li
2026-06-09 9:30 ` [PATCH 1/2] eal: return error on devargs truncation in hotplug MP messages David Marchand
2026-06-24 0:06 ` [EXTERNAL] " Long Li
2026-06-24 0:05 ` [PATCH v2] " Long Li
2026-06-25 7:23 ` David Marchand
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=20260325014506.1866374-1-longli@microsoft.com \
--to=longli@microsoft.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.