From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Kiran Kumar K <kirankumark@marvell.com>,
Stephen Hemminger <stephen@networkplumber.org>,
stable@dpdk.org, Aman Singh <aman.deep.singh@intel.com>,
Gregory Etelson <getelson@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Subject: [PATCH 1/3] app/testpmd: fix stack overflow parsing flex item link
Date: Mon, 7 Sep 2026 11:22:02 -0700 [thread overview]
Message-ID: <20260907182317.570481-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20260907182317.570481-1-stephen@networkplumber.org>
The item string in a flex item JSON configuration is formatted into a
256 byte stack buffer with sprintf(). A longer string overflows it:
*** buffer overflow detected ***: terminated
Use snprintf() and reject the item if it does not fit.
Fixes: 59f3a8acbcdb ("app/testpmd: add flex item commands")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test-pmd/cmd_flex_item.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/app/test-pmd/cmd_flex_item.c b/app/test-pmd/cmd_flex_item.c
index c0bbff7b45..e62afe3cb5 100644
--- a/app/test-pmd/cmd_flex_item.c
+++ b/app/test-pmd/cmd_flex_item.c
@@ -135,10 +135,13 @@ flex_link_item_parse(const char *src, struct rte_flow_item *item)
struct rte_flow_item *pattern;
struct rte_flow_action *actions;
- sprintf(flow_rule,
- "flow create 0 pattern %s / end actions drop / end", src);
- src = flow_rule;
- ret = flow_parse(src, (void *)data, sizeof(data),
+ ret = snprintf(flow_rule, sizeof(flow_rule),
+ "flow create 0 pattern %s / end actions drop / end", src);
+ if (ret < 0 || ret >= (int)sizeof(flow_rule)) {
+ printf("Flex item link \"%s\" is too long\n", src);
+ return -ENOSPC;
+ }
+ ret = flow_parse(flow_rule, (void *)data, sizeof(data),
&attr, &pattern, &actions);
if (ret)
return ret;
--
2.53.0
next prev parent reply other threads:[~2026-09-07 18:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 18:22 [PATCH 0/3] app/testpmd: fix more overflow issues Stephen Hemminger
2026-09-07 18:22 ` Stephen Hemminger [this message]
2026-09-07 18:22 ` [PATCH 2/3] app/testpmd: fix flex item allocation overlap Stephen Hemminger
2026-09-07 18:22 ` [PATCH 3/3] app/testpmd: fix null dereference parsing flex item link Stephen Hemminger
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=20260907182317.570481-2-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=aman.deep.singh@intel.com \
--cc=dev@dpdk.org \
--cc=getelson@nvidia.com \
--cc=kirankumark@marvell.com \
--cc=stable@dpdk.org \
--cc=viacheslavo@nvidia.com \
/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.