From: Gregory Etelson <getelson@nvidia.com>
To: <dev@dpdk.org>
Cc: <getelson@nvidia.com>, <mkashani@nvidia.com>,
<ferruh.yigit@amd.com>, <stable@dpdk.org>,
Ori Kam <orika@nvidia.com>,
Aman Singh <aman.deep.singh@intel.com>,
Yuying Zhang <yuying.zhang@intel.com>,
"Olga Shern" <olgas@nvidia.com>,
Adrien Mazarguil <adrien.mazarguil@6wind.com>
Subject: [PATCH] app/testpmd: add size validation to token parsers
Date: Sat, 11 Nov 2023 09:13:47 +0200 [thread overview]
Message-ID: <20231111071347.71824-1-getelson@nvidia.com> (raw)
parse_prefix(), parse_int(), parse_mac_addr(),
parse_ipv4_addr() and parse_ipv6_addr() unconditionally overwrite
the `size` parameter with token size.
The `size` parameter references a buffer where the parser functions
will store their result.
If the `size` value was less than token size, parser will corrupt
memory outsite of target buffer.
The patch adds sizes validation.
Fixes: d3f61b7bad20 ("app/testpmd: add flow item spec prefix length")
Fixes: 8a03ab58cc0a ("app/testpmd: support flow integer")
Fixes: 6df81b325fa4 ("app/testpmd: add items eth/vlan to flow command")
Fixes: ef6e38550f07 ("app/testpmd: add items ipv4/ipv6 to flow command")
Cc: stable@dpdk.org
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
app/test-pmd/cmdline_flow.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index ce71818705..87541d2c46 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -7715,6 +7715,8 @@ parse_prefix(struct context *ctx, const struct token *token,
}
bytes = u / 8;
extra = u % 8;
+ if (size < arg->size)
+ goto error;
size = arg->size;
if (bytes > size || bytes + !!extra > size)
goto error;
@@ -10806,6 +10808,8 @@ parse_int(struct context *ctx, const struct token *token,
return len;
}
buf = (uint8_t *)ctx->object + arg->offset;
+ if (size < arg->size)
+ goto error;
size = arg->size;
if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
return -1;
@@ -11093,6 +11097,8 @@ parse_mac_addr(struct context *ctx, const struct token *token,
/* Argument is expected. */
if (!arg)
return -1;
+ if (size < arg->size)
+ goto error;
size = arg->size;
/* Bit-mask fill is not supported. */
if (arg->mask || size != sizeof(tmp))
@@ -11134,6 +11140,8 @@ parse_ipv4_addr(struct context *ctx, const struct token *token,
/* Argument is expected. */
if (!arg)
return -1;
+ if (size < arg->size)
+ goto error;
size = arg->size;
/* Bit-mask fill is not supported. */
if (arg->mask || size != sizeof(tmp))
@@ -11181,6 +11189,8 @@ parse_ipv6_addr(struct context *ctx, const struct token *token,
/* Argument is expected. */
if (!arg)
return -1;
+ if (size < arg->size)
+ goto error;
size = arg->size;
/* Bit-mask fill is not supported. */
if (arg->mask || size != sizeof(tmp))
--
2.39.2
next reply other threads:[~2023-11-11 7:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-11 7:13 Gregory Etelson [this message]
2024-02-08 14:45 ` Ferruh Yigit
2024-02-09 15:07 ` Ferruh Yigit
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=20231111071347.71824-1-getelson@nvidia.com \
--to=getelson@nvidia.com \
--cc=adrien.mazarguil@6wind.com \
--cc=aman.deep.singh@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=mkashani@nvidia.com \
--cc=olgas@nvidia.com \
--cc=orika@nvidia.com \
--cc=stable@dpdk.org \
--cc=yuying.zhang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).