patch 'cmdline: harden parser result buffer handling' has been queued to stable release 25.11.3
Kevin Traynor
ktraynor at redhat.com
Thu Jul 23 19:14:27 CEST 2026
Hi,
FYI, your patch has been queued to stable release 25.11.3
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 07/27/26. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable
This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/777c899b8e61e28a165f9f1efffc009550363a8a
Thanks.
Kevin
---
>From 777c899b8e61e28a165f9f1efffc009550363a8a Mon Sep 17 00:00:00 2001
From: Bruce Richardson <bruce.richardson at intel.com>
Date: Thu, 7 May 2026 15:59:46 +0100
Subject: [PATCH] cmdline: harden parser result buffer handling
[ upstream commit 0d89b5f60778d4a5e22076c9487d33fb81f4e44b ]
The cmdline parser had a few result-buffer safety gaps.
In boolean token parsing, the parser could write through a NULL output
pointer in parse-only paths (for example completion/match checks). Add
proper output-pointer and output-size checks before storing the parsed
value.
In instruction matching, reject token offsets that are equal to the
result buffer size, not only greater than it, so tokens are never parsed
with a zero-sized output window at the end of the buffer.
In completion formatting, handle truncated strlcpy() output before
appending help text, preventing offset/size misuse when the destination
buffer is small.
Fixes: 985465997b73 ("ethdev: add xstats API to enable/disable counter")
Fixes: af75078fece3 ("first public release")
Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
lib/cmdline/cmdline_parse.c | 6 ++++--
lib/cmdline/cmdline_parse_bool.c | 19 ++++++++++++++++---
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/lib/cmdline/cmdline_parse.c b/lib/cmdline/cmdline_parse.c
index 201fddb8c3..d55c8db19d 100644
--- a/lib/cmdline/cmdline_parse.c
+++ b/lib/cmdline/cmdline_parse.c
@@ -134,5 +134,5 @@ match_inst(cmdline_parse_inst_t *inst, const char *buf,
unsigned rb_sz;
- if (token_hdr.offset > resbuf_size) {
+ if (token_hdr.offset >= resbuf_size) {
printf("Parse error(%s:%d): Token offset(%u) "
"exceeds maximum size(%u)\n",
@@ -520,5 +520,7 @@ cmdline_complete(struct cmdline *cl, const char *buf, int *state,
(*state)++;
l=strlcpy(dst, tmpbuf, size);
- if (l>=0 && token_hdr.ops->get_help) {
+ if ((unsigned int)l >= size)
+ return 1;
+ if (token_hdr.ops->get_help) {
token_hdr.ops->get_help(token_p, tmpbuf,
sizeof(tmpbuf));
diff --git a/lib/cmdline/cmdline_parse_bool.c b/lib/cmdline/cmdline_parse_bool.c
index e03cc3d545..a3f7adab58 100644
--- a/lib/cmdline/cmdline_parse_bool.c
+++ b/lib/cmdline/cmdline_parse_bool.c
@@ -36,7 +36,15 @@ static cmdline_parse_token_string_t cmd_parse_token_bool = {
int
cmdline_parse_bool(__rte_unused cmdline_parse_token_hdr_t *tk, const char *srcbuf, void *res,
- __rte_unused unsigned int ressize)
+ unsigned int ressize)
{
cmdline_fixed_string_t on_off = {0};
+ uint8_t val;
+
+ if (!srcbuf || !*srcbuf)
+ return -1;
+
+ if (res != NULL && ressize < sizeof(uint8_t))
+ return -1;
+
if (cmdline_token_string_ops.parse
(&cmd_parse_token_bool.hdr, srcbuf, on_off, sizeof(on_off)) < 0)
@@ -44,7 +52,12 @@ cmdline_parse_bool(__rte_unused cmdline_parse_token_hdr_t *tk, const char *srcbu
if (strcmp((char *)on_off, "on") == 0)
- *(uint8_t *)res = 1;
+ val = 1;
else if (strcmp((char *)on_off, "off") == 0)
- *(uint8_t *)res = 0;
+ val = 0;
+ else
+ return -1;
+
+ if (res != NULL)
+ *(uint8_t *)res = val;
return strlen(on_off);
--
2.55.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-07-23 17:57:58.839280568 +0100
+++ 0004-cmdline-harden-parser-result-buffer-handling.patch 2026-07-23 17:57:58.625322492 +0100
@@ -1 +1 @@
-From 0d89b5f60778d4a5e22076c9487d33fb81f4e44b Mon Sep 17 00:00:00 2001
+From 777c899b8e61e28a165f9f1efffc009550363a8a Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 0d89b5f60778d4a5e22076c9487d33fb81f4e44b ]
+
@@ -23 +24,0 @@
-Cc: stable at dpdk.org
More information about the stable
mailing list