* [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
* [PATCH 2/2] eal: add meson options for hotplug MP message buffer sizes
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 ` Long Li
2026-03-25 2:44 ` Stephen Hemminger
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
Add meson build options to allow increasing the multi-process hotplug
message buffer limits at build time for deployments with many NICs:
- 'dev_mp_devargs_max_len' (default 128): max device args length
- 'mp_max_param_len' (default 256): max MP IPC message param length
Example: meson setup build -Ddev_mp_devargs_max_len=256 -Dmp_max_param_len=512
Guard the existing #defines with #ifndef so the meson-generated values
from rte_build_config.h take precedence when overridden.
Add a static_assert to ensure eal_dev_mp_req fits within the MP message
param buffer, catching misconfiguration at compile time.
Note: all primary and secondary processes must be built with the same
values, as these sizes affect shared IPC message struct layouts.
Signed-off-by: Long Li <longli@microsoft.com>
---
config/meson.build | 2 ++
lib/eal/common/hotplug_mp.h | 6 ++++++
lib/eal/include/rte_eal.h | 2 ++
meson_options.txt | 4 ++++
4 files changed, 14 insertions(+)
diff --git a/config/meson.build b/config/meson.build
index 9ba7b9a338..d0c117dbc9 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -385,6 +385,8 @@ dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
dpdk_conf.set('RTE_ENABLE_STDATOMIC', get_option('enable_stdatomic'))
dpdk_conf.set('RTE_ENABLE_TRACE_FP', get_option('enable_trace_fp'))
dpdk_conf.set('RTE_PKTMBUF_HEADROOM', get_option('pkt_mbuf_headroom'))
+dpdk_conf.set('RTE_MP_MAX_PARAM_LEN', get_option('mp_max_param_len'))
+dpdk_conf.set('EAL_DEV_MP_DEV_ARGS_MAX_LEN', get_option('dev_mp_devargs_max_len'))
# values which have defaults which may be overridden
dpdk_conf.set('RTE_MAX_VFIO_GROUPS', 64)
dpdk_conf.set('RTE_DRIVER_MEMPOOL_BUCKET_SIZE_KB', 64)
diff --git a/lib/eal/common/hotplug_mp.h b/lib/eal/common/hotplug_mp.h
index 7221284286..df8f987ea6 100644
--- a/lib/eal/common/hotplug_mp.h
+++ b/lib/eal/common/hotplug_mp.h
@@ -6,13 +6,16 @@
#define _HOTPLUG_MP_H_
#include "rte_dev.h"
+#include "rte_eal.h"
#define EAL_DEV_MP_ACTION_REQUEST "eal_dev_mp_request"
#define EAL_DEV_MP_ACTION_RESPONSE "eal_dev_mp_response"
#define EAL_DEV_MP_DEV_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
#define EAL_DEV_MP_BUS_NAME_MAX_LEN 32
+#ifndef EAL_DEV_MP_DEV_ARGS_MAX_LEN
#define EAL_DEV_MP_DEV_ARGS_MAX_LEN 128
+#endif
enum eal_dev_req_type {
EAL_DEV_REQ_TYPE_ATTACH,
@@ -27,6 +30,9 @@ struct eal_dev_mp_req {
int result;
};
+static_assert(sizeof(struct eal_dev_mp_req) <= RTE_MP_MAX_PARAM_LEN,
+ "eal_dev_mp_req exceeds RTE_MP_MAX_PARAM_LEN, increase mp_max_param_len");
+
/**
* Register all mp action callbacks for hotplug.
*
diff --git a/lib/eal/include/rte_eal.h b/lib/eal/include/rte_eal.h
index 7241f3be5d..aef431a88a 100644
--- a/lib/eal/include/rte_eal.h
+++ b/lib/eal/include/rte_eal.h
@@ -158,7 +158,9 @@ bool rte_mp_disable(void);
#define RTE_MP_MAX_FD_NUM 253 /* The max amount of fds (see SCM_MAX_FD) */
#define RTE_MP_MAX_NAME_LEN 64 /* The max length of action name */
+#ifndef RTE_MP_MAX_PARAM_LEN
#define RTE_MP_MAX_PARAM_LEN 256 /* The max length of param */
+#endif
struct rte_mp_msg {
char name[RTE_MP_MAX_NAME_LEN];
int len_param;
diff --git a/meson_options.txt b/meson_options.txt
index e28d24054c..c6d07a3308 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -48,6 +48,10 @@ option('mbuf_refcnt_atomic', type: 'boolean', value: true, description:
'Atomically access the mbuf refcnt.')
option('platform', type: 'string', value: 'native', description:
'Platform to build, either "native", "generic" or a SoC. Please refer to the Linux build guide for more information.')
+option('mp_max_param_len', type: 'integer', value: 256, description:
+ 'Maximum length of parameters in multi-process IPC messages.')
+option('dev_mp_devargs_max_len', type: 'integer', value: 128, description:
+ 'Maximum length of device arguments in multi-process hotplug messages.')
option('pkt_mbuf_headroom', type: 'integer', value: 128, description:
'Default data offset (in bytes) in a packet buffer to leave room for additional headers.')
option('enable_stdatomic', type: 'boolean', value: false, description:
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] eal: add meson options for hotplug MP message buffer sizes
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
0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2026-03-25 2:44 UTC (permalink / raw)
To: Long Li; +Cc: dev, bruce.richardson
On Tue, 24 Mar 2026 18:45:06 -0700
Long Li <longli@microsoft.com> wrote:
> Add meson build options to allow increasing the multi-process hotplug
> message buffer limits at build time for deployments with many NICs:
> - 'dev_mp_devargs_max_len' (default 128): max device args length
> - 'mp_max_param_len' (default 256): max MP IPC message param length
>
> Example: meson setup build -Ddev_mp_devargs_max_len=256 -Dmp_max_param_len=512
>
> Guard the existing #defines with #ifndef so the meson-generated values
> from rte_build_config.h take precedence when overridden.
>
> Add a static_assert to ensure eal_dev_mp_req fits within the MP message
> param buffer, catching misconfiguration at compile time.
>
> Note: all primary and secondary processes must be built with the same
> values, as these sizes affect shared IPC message struct layouts.
>
> Signed-off-by: Long Li <longli@microsoft.com>
The whole mp API needs some work on sizing.
Ideally the message would be variable size and not include all the
file descriptors if not needed.
Even better it should be TLV encoded instead of fixed structure.
But doing this probably has to wait until 26.11.
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [EXTERNAL] Re: [PATCH 2/2] eal: add meson options for hotplug MP message buffer sizes
2026-03-25 2:44 ` Stephen Hemminger
@ 2026-03-25 18:42 ` Long Li
0 siblings, 0 replies; 4+ messages in thread
From: Long Li @ 2026-03-25 18:42 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev@dpdk.org, bruce.richardson@intel.com
> On Tue, 24 Mar 2026 18:45:06 -0700
> Long Li <longli@microsoft.com> wrote:
>
> > Add meson build options to allow increasing the multi-process hotplug
> > message buffer limits at build time for deployments with many NICs:
> > - 'dev_mp_devargs_max_len' (default 128): max device args length
> > - 'mp_max_param_len' (default 256): max MP IPC message param length
> >
> > Example: meson setup build -Ddev_mp_devargs_max_len=256
> > -Dmp_max_param_len=512
> >
> > Guard the existing #defines with #ifndef so the meson-generated values
> > from rte_build_config.h take precedence when overridden.
> >
> > Add a static_assert to ensure eal_dev_mp_req fits within the MP
> > message param buffer, catching misconfiguration at compile time.
> >
> > Note: all primary and secondary processes must be built with the same
> > values, as these sizes affect shared IPC message struct layouts.
> >
> > Signed-off-by: Long Li <longli@microsoft.com>
>
>
>
> The whole mp API needs some work on sizing.
> Ideally the message would be variable size and not include all the file
> descriptors if not needed.
>
> Even better it should be TLV encoded instead of fixed structure.
> But doing this probably has to wait until 26.11.
Will work on it.
Can you take the 1st patch in the series?
eal: return error on devargs truncation in hotplug MP messages.
Thanks,
Long
^ permalink raw reply [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