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 9E611A0547; Thu, 29 Apr 2021 15:13:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E261410DD; Thu, 29 Apr 2021 15:13:03 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id A3DBB406FF for ; Thu, 29 Apr 2021 15:13:01 +0200 (CEST) IronPort-SDR: JmfC0tDc7cfzW8ZoBuU8zJIkiyxsAiqtQCwP9QNqbgh8kLFSJ1pxwCqW5Ku9yT1K1xjMdU5OAR 7FCzgt5/t1ug== X-IronPort-AV: E=McAfee;i="6200,9189,9969"; a="184132038" X-IronPort-AV: E=Sophos;i="5.82,259,1613462400"; d="scan'208";a="184132038" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2021 06:13:00 -0700 IronPort-SDR: G1f2qjCdJm/MAVROvsv78QKyw4gKQI1NlIqsecGmFbeDn14ORPvztSvXE/czi8MTgx0gexfJVu IOOCGxvakjLg== X-IronPort-AV: E=Sophos;i="5.82,259,1613462400"; d="scan'208";a="526937386" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.208.65]) ([10.213.208.65]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2021 06:12:59 -0700 To: Jiawen Wu , "'Min Hu (Connor)'" Cc: dev@dpdk.org References: <1619355269-14802-1-git-send-email-humin29@huawei.com> <57d60499-2ff9-fe16-aa97-93deb6e2cdc6@intel.com> <008901d73ca8$a3e2efd0$eba8cf70$@trustnetic.com> From: Ferruh Yigit X-User: ferruhy Message-ID: <69f0bcb9-7d5d-6d0a-8e93-caf0203cab09@intel.com> Date: Thu, 29 Apr 2021 14:12:55 +0100 MIME-Version: 1.0 In-Reply-To: <008901d73ca8$a3e2efd0$eba8cf70$@trustnetic.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] net/txgbe: fix null pointer check problem 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 Sender: "dev" On 4/29/2021 4:35 AM, Jiawen Wu wrote: > On April 27, 2021 11:31 PM, Ferruh Yigit wrote: >> On 4/25/2021 1:54 PM, Min Hu (Connor) wrote: >>> From: HongBo Zheng >>> >>> In function cons_parse_ntuple_filter, item->spec and item->mask should >>> be confirmed not null before use memcmp on it, current judgement >>> (item->spec || item->mask) just can confirm item->spec or item->mask >>> is not null, and cause null pointer be used in memcmp. >>> >>> This patch fix this problem. >>> >>> Fixes: b7eeecb17556 ("net/txgbe: parse n-tuple filter") >>> Cc: stable@dpdk.org >>> >>> Signed-off-by: HongBo Zheng >>> Signed-off-by: Min Hu (Connor) >>> --- >>> drivers/net/txgbe/txgbe_flow.c | 18 ++++++++---------- >>> 1 file changed, 8 insertions(+), 10 deletions(-) >>> >>> diff --git a/drivers/net/txgbe/txgbe_flow.c >>> b/drivers/net/txgbe/txgbe_flow.c index 57a4f2e..35026ee 100644 >>> --- a/drivers/net/txgbe/txgbe_flow.c >>> +++ b/drivers/net/txgbe/txgbe_flow.c >>> @@ -240,11 +240,10 @@ cons_parse_ntuple_filter(const struct >> rte_flow_attr *attr, >>> return -rte_errno; >>> } >>> /* if the first item is MAC, the content should be NULL */ >>> - if ((item->spec || item->mask) && >>> - (memcmp(eth_spec, ð_null, >>> - sizeof(struct rte_flow_item_eth)) || >>> - memcmp(eth_mask, ð_null, >>> - sizeof(struct rte_flow_item_eth)))) { >>> + if ((item->spec && memcmp(eth_spec, ð_null, >>> + sizeof(struct rte_flow_item_eth))) || >>> + (item->mask && memcmp(eth_mask, ð_null, >>> + sizeof(struct rte_flow_item_eth)))) { >>> rte_flow_error_set(error, EINVAL, >>> RTE_FLOW_ERROR_TYPE_ITEM, >>> item, "Not supported by ntuple filter"); @@ -272,11 >> +271,10 @@ >>> cons_parse_ntuple_filter(const struct rte_flow_attr *attr, >>> return -rte_errno; >>> } >>> /* the content should be NULL */ >>> - if ((item->spec || item->mask) && >>> - (memcmp(vlan_spec, &vlan_null, >>> - sizeof(struct rte_flow_item_vlan)) || >>> - memcmp(vlan_mask, &vlan_null, >>> - sizeof(struct rte_flow_item_vlan)))) { >>> + if ((item->spec && memcmp(vlan_spec, &vlan_null, >>> + sizeof(struct rte_flow_item_vlan))) || >>> + (item->mask && memcmp(vlan_mask, &vlan_null, >>> + sizeof(struct rte_flow_item_vlan)))) { >>> rte_flow_error_set(error, EINVAL, >>> RTE_FLOW_ERROR_TYPE_ITEM, >>> item, "Not supported by ntuple filter"); >>> >> >> Looks good to me, but lets wait or maintainers review. > > Thanks. > Acked-by: Jiawen Wu > Applied to dpdk-next-net/main, thanks.