DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Daniil Iskhakov <dish@amicon.ru>
Cc: <dev@dpdk.org>, Anatoly Burakov <anatoly.burakov@intel.com>,
	"Vladimir Medvedkin" <vladimir.medvedkin@intel.com>,
	Wei Zhao <wei.zhao1@intel.com>, Wenzhuo Lu <wenzhuo.lu@intel.com>,
	<stable@dpdk.org>, Daniil Agalakov <ade@amicon.ru>,
	<sdl.dpdk@linuxtesting.org>, <rrv@amicon.ru>
Subject: Re: [PATCH] net/ixgbe: incorrect MAC/VLAN item validation for ntuple
Date: Tue, 5 May 2026 16:19:26 +0100	[thread overview]
Message-ID: <afoKfpPQFn6Z9bVp@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <20260427151605.1789289-1-dish@amicon.ru>

On Mon, Apr 27, 2026 at 06:16:04PM +0300, Daniil Iskhakov wrote:
> When parsing an ntuple filter, the code attempts to ensure that if the
> first item is ETH (or VLAN), its spec and mask must be NULL (i.e.
> zeroed structure). The current check is:
> 
>   if ((item->spec || item->mask) &&
>       (memcmp(spec, &null_struct, size) ||
>           memcmp(mask, &null_struct, size)))
> 
> This condition is logically incorrect. If item->spec points to a
> zero-filled structure and item->mask is NULL, memcmp(mask) would
> dereference a NULL pointer.
> 
> The intention os code is to reject any non‑zero spec or mask.
> 
> Split the check into two independent conditions for spec and mask.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 46ea969177f3 ("net/ixgbe: add ntuple support to flow parser")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Daniil Agalakov <ade@amicon.ru>
> Signed-off-by: Daniil Iskhakov <dish@amicon.ru>
> ---
> Cc: wei.zhao1@intel.com
> Cc: sdl.dpdk@linuxtesting.org
> Cc: rrv@amicon.ru
> ---
>  drivers/net/intel/ixgbe/ixgbe_flow.c | 37 +++++++++++++++++-----------
>  1 file changed, 22 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/intel/ixgbe/ixgbe_flow.c b/drivers/net/intel/ixgbe/ixgbe_flow.c
> index 01cd4f9bde..9edfff413e 100644
> --- a/drivers/net/intel/ixgbe/ixgbe_flow.c
> +++ b/drivers/net/intel/ixgbe/ixgbe_flow.c
> @@ -238,14 +238,18 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
>  
>  		}
>  		/* if the first item is MAC, the content should be NULL */
> -		if ((item->spec || item->mask) &&
> -			(memcmp(eth_spec, &eth_null,
> -				sizeof(struct rte_flow_item_eth)) ||
> -			 memcmp(eth_mask, &eth_null,
> -				sizeof(struct rte_flow_item_eth)))) {
> +		if (item->spec && memcmp(eth_spec, &eth_null,
> +			sizeof(struct rte_flow_item_eth))) {
>  			rte_flow_error_set(error, EINVAL,
> -				RTE_FLOW_ERROR_TYPE_ITEM,
> -				item, "Not supported by ntuple filter");
> +			  RTE_FLOW_ERROR_TYPE_ITEM,
> +			  item, "Not supported by ntuple filter");
> +			return -rte_errno;
> +		}
> +		if (item->mask && memcmp(eth_mask, &eth_null,
> +			sizeof(struct rte_flow_item_eth))) {
> +			rte_flow_error_set(error, EINVAL,
> +			  RTE_FLOW_ERROR_TYPE_ITEM,
> +			  item, "Not supported by ntuple filter");
>  			return -rte_errno;
>  		}
>  		/* check if the next not void item is IPv4 or Vlan */

This fix looks correct. However, the indentation is wrong according to DPDK
coding style. Feel free to use up to 100 columns for the text, no need to
wrap at 80 columns if line fits in 100. If indenting the line continuation,
use either a double indent or align with brackets [Yes, original code is
wrong here too]. Our coding standards also recommend that we explicitly put
the checks in to compare pointers explicitly against null, and integer
return values against zero, rather than implicitly converting them to bool
as here.

Finally, what do you think about keeping the checks as a single condition? i.e.

if ((item->spec != NULL && memcmp(eth_spec, &eth_null, sizeof(eth_null)) != 0) ||
		(item->mask != NULL && memcmp(....))) {
	....
}

Regards,
/Bruce


      reply	other threads:[~2026-05-05 15:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 15:16 [PATCH] net/ixgbe: incorrect MAC/VLAN item validation for ntuple Daniil Iskhakov
2026-05-05 15:19 ` Bruce Richardson [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=afoKfpPQFn6Z9bVp@bricha3-mobl1.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=ade@amicon.ru \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=dish@amicon.ru \
    --cc=rrv@amicon.ru \
    --cc=sdl.dpdk@linuxtesting.org \
    --cc=stable@dpdk.org \
    --cc=vladimir.medvedkin@intel.com \
    --cc=wei.zhao1@intel.com \
    --cc=wenzhuo.lu@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