All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Anatoly Burakov <anatoly.burakov@intel.com>
Cc: dev@dpdk.org
Subject: Re: [PATCH v3 1/5] ethdev: fix flow conversion with null buffer
Date: Mon, 26 Oct 2026 09:51:08 -0700	[thread overview]
Message-ID: <20261026095108.7ea124df@phoenix.local> (raw)
In-Reply-To: <5698ccb3daeebd1d50346d5a3bd8471468056463.1792849824.git.anatoly.burakov@intel.com>

On Sat, 24 Oct 2026 14:50:28 +0100
Anatoly Burakov <anatoly.burakov@intel.com> wrote:

> rte_flow_conv_pattern() and rte_flow_conv_actions() document that the
> destination buffer may be NULL when the size is zero, which is how
> callers query the number of bytes required before allocating. Both
> functions nonetheless walked the destination with ++dst in the first
> pass and dst -= num before the second, regardless of size.
> 
> Pointer arithmetic on a NULL pointer is undefined behavior, and is
> reported by UBSan as "applying non-zero offset to null pointer" for
> every RTE_FLOW_CONV_OP_PATTERN and RTE_FLOW_CONV_OP_ACTIONS size query.
> 
> Keep the destination pointer fixed and index it only inside the
> size-guarded writes, which are never reached when size is zero.
> 
> Fixes: 063911ee1df4 ("ethdev: add flow API object converter")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---

Manually run AI review sees some problems.

Subject: Re: [PATCH v3 0/5] ethdev: flow conversion fixes

Series applies cleanly to main and each commit builds with
-Dwerror=true. Descriptor tables now cover every item type through
COMPARE and every action type through JUMP_TO_TABLE_INDEX.

One correctness problem in 3/5, plus a pre-existing out-of-bounds
write on the same code path that should be fixed while here.


[PATCH v3 3/5] ethdev: fix missing flow action descriptors

Error: SHARED is now accepted but its handle is not preserved.

The new entry is MK_FLOW_ACTION(SHARED, 0) with a comment saying the
handle is stored in conf as for INDIRECT. rte_flow_conv_actions()
only special-cases RTE_FLOW_ACTION_TYPE_INDIRECT. SHARED with a
non-NULL conf falls into the generic branch, rte_flow_conv_copy()
copies zero bytes (desc size 0), and dst[i].conf is set to
data + off, a pointer into the output buffer instead of the handle.

Before this patch SHARED was rejected with ENOTSUP. After it,
rte_flow_conv() and rte_flow_copy() succeed and return a corrupted
action. Handle it the same way as INDIRECT:

-		if (src->type == RTE_FLOW_ACTION_TYPE_INDIRECT) {
+		if (src->type == RTE_FLOW_ACTION_TYPE_INDIRECT ||
+		    src->type == RTE_FLOW_ACTION_TYPE_SHARED) {

Either that, or leave SHARED out of the table since it is deprecated;
but then the completeness test in 4/5 needs an exception for it.

Please add a SHARED action with a non-NULL conf to
test_flow_conv_actions() and check out[i].conf == actions[i].conf.
That would have caught this.


[PATCH v3 1/5] ethdev: fix flow conversion with null buffer

Warning: INDIRECT conf write is not bounded by the buffer size.

Pre-existing, but this patch rewrites the line. In the second pass:

	if (size)
		dst[i].conf = src->conf;

Every other write into dst[] is guarded by size covering the entry.
With actions { QUEUE, INDIRECT, END } and size equal to
sizeof(struct rte_flow_action), the first pass writes only dst[0],
then the second pass writes dst[1].conf past the end of the caller's
buffer. Suggest:

-			if (size)
+			if (size >= (i + 1) * sizeof(*dst))
 				dst[i].conf = src->conf;

This also covers SHARED once 3/5 routes it through the same branch.


[PATCH v3 5/5] ethdev: add flow item structure size query

Info: the NULL name checks added to rte_flow_conv_name() and
rte_flow_conv_item_default_mask() are hardening for the strlcpy(NULL)
case described in 2/5 and 3/5. With those two patches applied there
are no gaps left, so this is fine in a feature patch. If you want the
check backported, move it into 2/5 instead.

  parent reply	other threads:[~2026-10-26 16:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 12:15 [PATCH v1 1/1] ethdev: add flow item structure size query Anatoly Burakov
2026-10-23 16:04 ` Stephen Hemminger
2026-10-24 12:04 ` [PATCH v2 1/4] ethdev: fix missing MACsec flow item descriptor Anatoly Burakov
2026-10-24 12:04   ` [PATCH v2 2/4] ethdev: fix missing flow action descriptors Anatoly Burakov
2026-10-24 12:04   ` [PATCH v2 3/4] test/ethdev: add flow conversion tests Anatoly Burakov
2026-10-24 12:04   ` [PATCH v2 4/4] ethdev: add flow item structure size query Anatoly Burakov
2026-10-24 13:50 ` [PATCH v3 1/5] ethdev: fix flow conversion with null buffer Anatoly Burakov
2026-10-24 13:50   ` [PATCH v3 2/5] ethdev: fix missing MACsec flow item descriptor Anatoly Burakov
2026-10-24 13:50   ` [PATCH v3 3/5] ethdev: fix missing flow action descriptors Anatoly Burakov
2026-10-24 13:50   ` [PATCH v3 4/5] test/ethdev: add flow conversion tests Anatoly Burakov
2026-10-24 13:50   ` [PATCH v3 5/5] ethdev: add flow item structure size query Anatoly Burakov
2026-10-26 16:51   ` Stephen Hemminger [this message]
2026-10-27 10:56     ` [PATCH v3 1/5] ethdev: fix flow conversion with null buffer Burakov, Anatoly
2026-10-27  9:50 ` [PATCH v4 1/6] " Anatoly Burakov
2026-10-27  9:50   ` [PATCH v4 2/6] ethdev: fix missing MACsec flow item descriptor Anatoly Burakov
2026-10-27  9:50   ` [PATCH v4 3/6] ethdev: fix missing flow action descriptors Anatoly Burakov
2026-10-27 13:59     ` Stephen Hemminger
2026-10-27  9:50   ` [PATCH v4 4/6] ethdev: fix indirect action conversion with short buffer Anatoly Burakov
2026-10-27  9:50   ` [PATCH v4 5/6] test/ethdev: add flow conversion tests Anatoly Burakov
2026-10-27  9:50   ` [PATCH v4 6/6] ethdev: add flow item structure size query Anatoly Burakov

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=20261026095108.7ea124df@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    /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.