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 E50EFA0A02; Tue, 27 Apr 2021 17:31:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 538B9410FD; Tue, 27 Apr 2021 17:31:16 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 4A9C2410D8 for ; Tue, 27 Apr 2021 17:31:14 +0200 (CEST) IronPort-SDR: 5ekEprgVJ86rvmzYbsB76DAPPM8URjkjgdcDiN8k+FU13/xfJbq1Hp6qfFgDZRUhwRozVNPKtZ NgrNKz/CFiNg== X-IronPort-AV: E=McAfee;i="6200,9189,9967"; a="260484957" X-IronPort-AV: E=Sophos;i="5.82,254,1613462400"; d="scan'208";a="260484957" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2021 08:31:07 -0700 IronPort-SDR: Zm2RuFvJ/B3+XGd1cNL4rVXciQ0pULTiZJrMT8TEXTdXbEgRqAvWlm3AlY1Zk+5VRHpTyTXuqT 3WKtqu/8yxtg== X-IronPort-AV: E=Sophos;i="5.82,254,1613462400"; d="scan'208";a="457689860" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.221.231]) ([10.213.221.231]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2021 08:31:05 -0700 To: "Min Hu (Connor)" , jiawenwu@trustnetic.com, jianwang@trustnetic.com Cc: dev@dpdk.org References: <1619355269-14802-1-git-send-email-humin29@huawei.com> From: Ferruh Yigit X-User: ferruhy Message-ID: <57d60499-2ff9-fe16-aa97-93deb6e2cdc6@intel.com> Date: Tue, 27 Apr 2021 16:30:58 +0100 MIME-Version: 1.0 In-Reply-To: <1619355269-14802-1-git-send-email-humin29@huawei.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/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.