DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Junlong Wang <wang.junlong1@zte.com.cn>
Cc: dev@dpdk.org
Subject: Re: [PATCH v1 0/2] net/zxdh: fix issues reported by GCC analyzer
Date: Mon, 30 Nov 2026 16:33:29 -0800	[thread overview]
Message-ID: <20261130163329.21e9eb28@phoenix.local> (raw)
In-Reply-To: <20261128040458.3967016-1-wang.junlong1@zte.com.cn>

On Sat, 28 Nov 2026 12:04:56 +0800
Junlong Wang <wang.junlong1@zte.com.cn> wrote:

> Two memory safety issues in the zxdh driver, both found with
> gcc -fanalyzer:
> 
> - zxdh_get_res_info() copies a reply length taken from the device into
>   a caller buffer whose size it is not told. Both callers pass a
>   one-byte object, so an oversized length overwrites their stack, and
>   a length above the receive buffer size also overruns that buffer
>   (patch 1).
> - fd_flow_parse_pattern() and fd_flow_parse_action() allocate a flow
>   entry when rte_flow_validate() passes dh_flow as NULL, and free it
>   on only one exit, so every validate leaks memory (patch 2).
> 
> Junlong Wang (2):
>   net/zxdh: bound resource table reply length before copying
>   net/zxdh: avoid leaking flow entry on validation
> 
>  drivers/net/zxdh/zxdh_common.c | 24 ++++++++++----
>  drivers/net/zxdh/zxdh_flow.c   | 58 ++++++++++------------------------
>  2 files changed, 33 insertions(+), 49 deletions(-)
> 

Applied both to next-net and fixed the commit tag AI complained about.
You might want to look at the other Info: finding.

Review: [PATCH v1 0/2] net/zxdh: GCC analyzer fixes

Series applies cleanly to main (27.03-rc0) and builds with
-Dwerror=true at each commit.


[PATCH v1 1/2] net/zxdh: bound resource table reply length before copying

Warning:

  Fixes: hash is 10 characters; must be 12.

    Fixes: 6310e3976bba ("net/zxdh: get device backend infos")

Info:

  A short reply still returns success. Both callers need exactly
  one byte, but a reply with len == 0 passes the new check, copies
  nothing, and the caller returns its initializer (reps = 0) as the
  panel or hash id. That is the "wrong panel or hash id" outcome the
  commit message says it avoids. Since both callers want an exact
  size, reject anything else:

	if (tbl_reps->len != max_len ||
	    tbl_reps->len > ZXDH_RSC_TBL_CONTENT_LEN_MAX) {

  or have the callers check reps_len == sizeof(reps).

  The new length check returns -EINVAL while every other exit from
  zxdh_get_res_info() returns a ZXDH_BAR_MSG_* code. Callers only
  test != ZXDH_BAR_MSG_OK so it works, but ZXDH_BAR_MSG_ERR_LEN
  already exists for this case and keeps the return convention
  consistent.

      parent reply	other threads:[~2026-12-01  0:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28  4:04 [PATCH v1 0/2] net/zxdh: fix issues reported by GCC analyzer Junlong Wang
2026-11-28  4:04 ` [PATCH v1 1/2] net/zxdh: bound resource table reply length before copying Junlong Wang
2026-12-01  0:26   ` Stephen Hemminger
2026-11-28  4:04 ` [PATCH v1 2/2] net/zxdh: avoid leaking flow entry on validation Junlong Wang
2026-12-01  0:33 ` Stephen Hemminger [this message]

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=20261130163329.21e9eb28@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=wang.junlong1@zte.com.cn \
    /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