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 33C17A04FD for ; Mon, 28 Mar 2022 03:48:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 289EC42858; Mon, 28 Mar 2022 03:48:03 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id B32C440143; Mon, 28 Mar 2022 03:48:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648432081; x=1679968081; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Sxcy++TsYJfYaP0wgD1uc+A0zRJ0GvvcF6zdHbcvtI4=; b=ll3XjjnFoww5Bod18yeQuOhGfcbTtssPIfkvNr6/uV81OnCKu6R4scCY DnbzNofEFTZcfk9la7pqFPV+2Wft/I5c5thFn9EhUAzKo09XWaXLQpvAd XMSuhDNTqBwy0wR1FYbscGoPvXuqCHvgPh87Rq/CN5ylt7kOhr52fKS4x 8sDe4s0YbaY7nQS9OwDxSfRuaWuZX6XcbqBq1G7FsfsjICmfkUGitN9I0 4LUEtney1yd6zoJuL0tpDXZRiUJqz+JUMc4G9i3e1tdo4K9ASc/ukxrP7 m7EteUFngQvT2apYGZI0as80vZfMjaXhfZUhs/wfaQQ0M6rOoeBjB/bZ0 w==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="241044044" X-IronPort-AV: E=Sophos;i="5.90,216,1643702400"; d="scan'208";a="241044044" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2022 18:47:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,216,1643702400"; d="scan'208";a="545762258" Received: from dpdk-xuting-second.sh.intel.com ([10.67.116.150]) by orsmga007.jf.intel.com with ESMTP; 27 Mar 2022 18:47:57 -0700 From: Ting Xu To: dev@dpdk.org Cc: junfeng.guo@intel.com, Ting Xu , stable@dpdk.org, Qiming Yang , Qi Zhang Subject: [PATCH v2] net/ice: fix raw flow input pattern value change in FDIR Date: Mon, 28 Mar 2022 09:49:26 +0800 Message-Id: <20220328014926.20809-1-ting.xu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220318031650.2580-1-ting.xu@intel.com> References: <20220318031650.2580-1-ting.xu@intel.com> X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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..5ff1afac90 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -1868,10 +1868,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 udp_port = 0; uint16_t tmp_val = 0; uint8_t pkt_len = 0; @@ -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