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 214E4A04FF for ; Mon, 18 Apr 2022 08:57:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1933D410E6; Mon, 18 Apr 2022 08:57:56 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 2B41A40141; Mon, 18 Apr 2022 08:57:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650265074; x=1681801074; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=/EHNOOTh5I2hdNVwyUTQEQGYI5M5jP1TQQ5EUzFxTKo=; b=iR8Qq/o3Ubyihqxz7HqUYVwv7cYt7cFKesAO5mwsoiUdWx0O6xCEg9B1 8FpDWCRG1sbgXI3OzQZPXFYDBiG88W77nCx8G+3pjKMsL8fRtotwnxyBT DAivBuOV4+B3znCRR7lrJpq/TquVTWcxdxYq6ZNkyi7XN/2PSzC60/86V x3TcwUB6r3nTr+SgzAo4prFrBn+NwxmLdAvRPy1HJ0H5h1aCbYsME9CWC fRGsyJ5XN4b7H3wVTGXbo77RsxBEKbJ9itzB4PkHdfj2UPzjkBFUIrqNZ 7NcfN+T9ovQ8heUu3Fg8F7sFahtIKLyIF85rabdvUmNlE/Q+mePNs/4zm g==; X-IronPort-AV: E=McAfee;i="6400,9594,10320"; a="244048303" X-IronPort-AV: E=Sophos;i="5.90,269,1643702400"; d="scan'208";a="244048303" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2022 23:57:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,269,1643702400"; d="scan'208";a="554123343" Received: from dpdk-xuting-second.sh.intel.com ([10.67.116.150]) by orsmga007.jf.intel.com with ESMTP; 17 Apr 2022 23:57:48 -0700 From: Ting Xu To: dev@dpdk.org Cc: junfeng.guo@intel.com, Ting Xu , stable@dpdk.org, Qiming Yang , Qi Zhang Subject: [PATCH v3] net/ice: fix raw flow input pattern value change in FDIR Date: Mon, 18 Apr 2022 14:59:08 +0800 Message-Id: <20220418065908.57171-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 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