From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EEA2DA0093; Fri, 18 Mar 2022 04:15:26 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8DE1740E28; Fri, 18 Mar 2022 04:15:26 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 59E8340DF7; Fri, 18 Mar 2022 04:15:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647573324; x=1679109324; h=from:to:cc:subject:date:message-id; bh=Z8htglFzUEvWtIi7OJAc5NmmjTG+hU3liCDvuwthaGw=; b=JsQSHlY0aPYWpOIYOGMnINzc5bw/aIBrSQG/y7eXQ9zpVHGhmOPL+h3Q 81jq0VpLGl9yV3boVwHJRlu95pp9Ga5reX/RqRYWtcgGHZTR2cdB4xBqF iG+eBIqTxAZJ1FKbzgpRpmjK/MNVAIx30iGvQPsABFBaNnWsl/ww3Ph19 eBNssd7qGHJMJDY5NGw3wHbL6G5DiU87vcjuzo6v5TjfMsLj5Tuhdu80d uD8xiExY9rwrfHttcVqEarbbozYDhV58MdVABS1Yymygkk2du2HU2MuG9 xMWSqHpAke1r6ua0uh5egtEYA2f0WlUnz/LBoFjamc/VSU94naqLwGfpb g==; X-IronPort-AV: E=McAfee;i="6200,9189,10289"; a="255863404" X-IronPort-AV: E=Sophos;i="5.90,191,1643702400"; d="scan'208";a="255863404" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2022 20:15:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,191,1643702400"; d="scan'208";a="541642653" Received: from dpdk-xuting-second.sh.intel.com ([10.67.116.150]) by orsmga007.jf.intel.com with ESMTP; 17 Mar 2022 20:15:21 -0700 From: Ting Xu To: dev@dpdk.org Cc: junfeng.guo@intel.com, Ting Xu , stable@dpdk.org, Qiming Yang , Qi Zhang Subject: [PATCH] net/ice: fix raw flow input pattern value change in FDIR Date: Fri, 18 Mar 2022 11:16:50 +0800 Message-Id: <20220318031650.2580-1-ting.xu@intel.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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 7954c6d8ea..6e3851a71b 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -1868,14 +1868,15 @@ 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; uint16_t udp_port = 0; uint16_t tmp_val = 0; uint8_t pkt_len = 0; uint8_t tmp = 0; + uint8_t *tmp_spec, *tmp_mask; int i, j; pkt_len = strlen((char *)(uintptr_t)raw_spec->pattern); @@ -1883,8 +1884,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') @@ -1893,7 +1904,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') @@ -1901,7 +1912,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') @@ -1910,7 +1921,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') @@ -1953,6 +1964,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