patches for DPDK stable branches
 help / color / mirror / Atom feed
From: "Zhang, Qi Z" <qi.z.zhang@intel.com>
To: "Xu, Ting" <ting.xu@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "Guo, Junfeng" <junfeng.guo@intel.com>,
	"stable@dpdk.org" <stable@dpdk.org>,
	"Yang, Qiming" <qiming.yang@intel.com>
Subject: RE: [PATCH v3] net/ice: fix raw flow input pattern value change in FDIR
Date: Mon, 18 Apr 2022 07:29:57 +0000	[thread overview]
Message-ID: <35e91c70162a499eb6ce008584e42284@intel.com> (raw)
In-Reply-To: <20220418065908.57171-1-ting.xu@intel.com>



> -----Original Message-----
> From: Xu, Ting <ting.xu@intel.com>
> Sent: Monday, April 18, 2022 2:59 PM
> To: dev@dpdk.org
> Cc: Guo, Junfeng <junfeng.guo@intel.com>; Xu, Ting <ting.xu@intel.com>;
> stable@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Subject: [PATCH v3] net/ice: fix raw flow input pattern value change in FDIR
> 
> When parsing raw flow pattern in FDIR, the input parameter spec and mask
> are used directly and the original value will be changed. It will cause error if
> these values are used in other functions. In this patch, temporary variables
> are created to store the spec and mask.
> 
> Fixes: 25be39cc1760 ("net/ice: enable protocol agnostic flow offloading in
> FDIR")
> 
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ting Xu <ting.xu@intel.com>
> ---
>  drivers/net/ice/ice_fdir_filter.c | 25 +++++++++++++++++++------
>  1 file changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
> index 0982478feb..7914ba9407 100644
> --- a/drivers/net/ice/ice_fdir_filter.c
> +++ b/drivers/net/ice/ice_fdir_filter.c
> @@ -1870,10 +1870,11 @@ ice_fdir_parse_pattern(__rte_unused struct
> ice_adapter *ad,
>  				break;
> 
>  			/* convert raw spec & mask from byte string to int */
> -			unsigned char *tmp_spec =
> +			unsigned char *spec_pattern =
>  				(uint8_t *)(uintptr_t)raw_spec->pattern;
> -			unsigned char *tmp_mask =
> +			unsigned char *mask_pattern =
>  				(uint8_t *)(uintptr_t)raw_mask->pattern;
> +			uint8_t *tmp_spec, *tmp_mask;
>  			uint16_t tmp_val = 0;
>  			uint8_t pkt_len = 0;
>  			uint8_t tmp = 0;
> @@ -1884,8 +1885,18 @@ ice_fdir_parse_pattern(__rte_unused struct
> ice_adapter *ad,
>  				pkt_len)
>  				return -rte_errno;
> 
> +			tmp_spec = rte_zmalloc(NULL, pkt_len / 2, 0);
> +			if (!tmp_spec)
> +				return -rte_errno;
> +
> +			tmp_mask = rte_zmalloc(NULL, pkt_len / 2, 0);
> +			if (!tmp_mask) {
> +				rte_free(tmp_spec);
> +				return -rte_errno;
> +			}
> +
>  			for (i = 0, j = 0; i < pkt_len; i += 2, j++) {
> -				tmp = tmp_spec[i];
> +				tmp = spec_pattern[i];
>  				if (tmp >= 'a' && tmp <= 'f')
>  					tmp_val = tmp - 'a' + 10;
>  				if (tmp >= 'A' && tmp <= 'F')
> @@ -1894,7 +1905,7 @@ ice_fdir_parse_pattern(__rte_unused struct
> ice_adapter *ad,
>  					tmp_val = tmp - '0';
> 
>  				tmp_val *= 16;
> -				tmp = tmp_spec[i + 1];
> +				tmp = spec_pattern[i + 1];
>  				if (tmp >= 'a' && tmp <= 'f')
>  					tmp_spec[j] = tmp_val + tmp - 'a' + 10;
>  				if (tmp >= 'A' && tmp <= 'F')
> @@ -1902,7 +1913,7 @@ ice_fdir_parse_pattern(__rte_unused struct
> ice_adapter *ad,
>  				if (tmp >= '0' && tmp <= '9')
>  					tmp_spec[j] = tmp_val + tmp - '0';
> 
> -				tmp = tmp_mask[i];
> +				tmp = mask_pattern[i];
>  				if (tmp >= 'a' && tmp <= 'f')
>  					tmp_val = tmp - 'a' + 10;
>  				if (tmp >= 'A' && tmp <= 'F')
> @@ -1911,7 +1922,7 @@ ice_fdir_parse_pattern(__rte_unused struct
> ice_adapter *ad,
>  					tmp_val = tmp - '0';
> 
>  				tmp_val *= 16;
> -				tmp = tmp_mask[i + 1];
> +				tmp = mask_pattern[i + 1];
>  				if (tmp >= 'a' && tmp <= 'f')
>  					tmp_mask[j] = tmp_val + tmp - 'a' + 10;
>  				if (tmp >= 'A' && tmp <= 'F')
> @@ -1947,6 +1958,8 @@ ice_fdir_parse_pattern(__rte_unused struct
> ice_adapter *ad,
> 
>  			filter->parser_ena = true;
> 
> +			rte_free(tmp_spec);
> +			rte_free(tmp_mask);
>  			break;
>  		}
> 
> --
> 2.17.1

Added
Acked-by: Junfeng Guo <junfeng.guo@intel.com> from V2

Applied to dpdk-next-net-intel.

Thanks
Qi


      reply	other threads:[~2022-04-18  7:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-18  3:16 [PATCH] " Ting Xu
2022-03-25  6:33 ` Guo, Junfeng
2022-03-28  1:49 ` [PATCH v2] " Ting Xu
2022-04-14  1:27   ` Guo, Junfeng
2022-04-18  6:59 ` [PATCH v3] " Ting Xu
2022-04-18  7:29   ` Zhang, Qi Z [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=35e91c70162a499eb6ce008584e42284@intel.com \
    --to=qi.z.zhang@intel.com \
    --cc=dev@dpdk.org \
    --cc=junfeng.guo@intel.com \
    --cc=qiming.yang@intel.com \
    --cc=stable@dpdk.org \
    --cc=ting.xu@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).