public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
* [PATCH 1/2] eal: return error on devargs truncation in hotplug MP messages
@ 2026-03-25  1:45 Long Li
  2026-03-25  1:45 ` [PATCH 2/2] eal: add meson options for hotplug MP message buffer sizes Long Li
  0 siblings, 1 reply; 4+ messages in thread
From: Long Li @ 2026-03-25  1:45 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, stephen, Long Li

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-25 18:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-25  1:45 [PATCH 1/2] eal: return error on devargs truncation in hotplug MP messages Long Li
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox