From: Denis Lyulin <lyulin.2003@mail.ru>
To: Ori Kam <orika@nvidia.com>, Thomas Monjalon <thomas@monjalon.net>,
Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
Ferruh Yigit <ferruh.yigit@amd.com>,
Michael Baum <michaelba@nvidia.com>
Cc: dev@dpdk.org, stable@dpdk.org, adrien.mazarguil@6wind.com,
Denis Lyulin <lyulin.2003@mail.ru>
Subject: [PATCH] ethdev: fix pointer check in GENEVE and RAW flow copy
Date: Thu, 7 May 2026 14:20:11 +0300 [thread overview]
Message-ID: <20260507112012.119140-1-lyulin.2003@mail.ru> (raw)
When rte_flow_conv_item_spec() is called from rte_flow_conv_pattern(),
the spec, last and mask pointers are checked separately. If the API
is used incorrectly, the spec pointer may be NULL while last and mask
may be valid pointers.
In rte_flow_conv_item_spec() for GENVE_OPT and RAW item types the spec
pointer is used even if the function is called to copy last or mask.
It may cause a NULL pointer (spec) dereference.
This commit adds extra check of item->spec and if it is NULL, does not
copy further data relying on it
Fixes: 841a0445442d ("ethdev: fix GENEVE option item conversion")
Cc: michaelba@nvidia.com
Cc: adrien.mazarguil@6wind.com
Cc: stable@dpdk.org
Signed-off-by: Denis Lyulin <lyulin.2003@mail.ru>
---
lib/ethdev/rte_flow.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index fe8f43caff..7cf585e6f5 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -672,13 +672,17 @@ rte_flow_conv_item_spec(void *buf, const size_t size,
}),
size > sizeof(*dst.raw) ? sizeof(*dst.raw) : size);
off = sizeof(*dst.raw);
- if (type == RTE_FLOW_CONV_ITEM_SPEC ||
- (type == RTE_FLOW_CONV_ITEM_MASK &&
- ((spec.raw->length & mask.raw->length) >=
- (last.raw->length & mask.raw->length))))
- tmp = spec.raw->length & mask.raw->length;
- else
- tmp = last.raw->length & mask.raw->length;
+ if (spec.raw && last.raw) {
+ if (type == RTE_FLOW_CONV_ITEM_SPEC ||
+ (type == RTE_FLOW_CONV_ITEM_MASK &&
+ ((spec.raw->length & mask.raw->length) >=
+ (last.raw->length & mask.raw->length))))
+ tmp = spec.raw->length & mask.raw->length;
+ else
+ tmp = last.raw->length & mask.raw->length;
+ } else {
+ tmp = 0;
+ }
if (tmp) {
off = RTE_ALIGN_CEIL(off, sizeof(*dst.raw->pattern));
if (size >= off + tmp) {
@@ -696,8 +700,8 @@ rte_flow_conv_item_spec(void *buf, const size_t size,
spec.geneve_opt = item->spec;
src.geneve_opt = data;
dst.geneve_opt = buf;
- tmp = spec.geneve_opt->option_len << 2;
- if (size > 0 && src.geneve_opt->data) {
+ tmp = spec.geneve_opt ? (spec.geneve_opt->option_len << 2) : 0;
+ if (size > 0 && tmp > 0 && src.geneve_opt->data) {
deep_src = (void *)((uintptr_t)(dst.geneve_opt + 1));
dst.geneve_opt->data = rte_memcpy(deep_src,
src.geneve_opt->data,
--
2.34.1
reply other threads:[~2026-05-12 7:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260507112012.119140-1-lyulin.2003@mail.ru \
--to=lyulin.2003@mail.ru \
--cc=adrien.mazarguil@6wind.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=michaelba@nvidia.com \
--cc=orika@nvidia.com \
--cc=stable@dpdk.org \
--cc=thomas@monjalon.net \
/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