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 1C4D4A0C43; Fri, 24 Sep 2021 07:46:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D676540687; Fri, 24 Sep 2021 07:46:27 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 8705D40142; Fri, 24 Sep 2021 07:46:26 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10116"; a="224051346" X-IronPort-AV: E=Sophos;i="5.85,319,1624345200"; d="scan'208";a="224051346" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2021 22:46:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,319,1624345200"; d="scan'208";a="534860114" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga004.fm.intel.com with ESMTP; 23 Sep 2021 22:46:25 -0700 Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Thu, 23 Sep 2021 22:46:24 -0700 Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by SHSMSX601.ccr.corp.intel.com (10.109.6.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Fri, 24 Sep 2021 13:46:22 +0800 Received: from shsmsx601.ccr.corp.intel.com ([10.109.6.141]) by SHSMSX601.ccr.corp.intel.com ([10.109.6.141]) with mapi id 15.01.2242.012; Fri, 24 Sep 2021 13:46:22 +0800 From: "Zhang, Qi Z" To: "Su, Simei" , "Yu, DapengX" , "Yang, Qiming" CC: "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [PATCH] net/ice: fix double free ACL flow entry Thread-Index: AQHXoKsQ7YLCU5xtLUuhPS+MjFSVQ6uyRgeAgACHjsA= Date: Fri, 24 Sep 2021 05:46:22 +0000 Message-ID: <28f12cff0f3e4e09ac612f4d6a7a8de8@intel.com> References: <20210903100411.1693789-1-dapengx.yu@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.6.200.16 dlp-product: dlpe-windows x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] net/ice: fix double free ACL flow entry 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" > -----Original Message----- > From: Su, Simei > Sent: Friday, September 24, 2021 1:41 PM > To: Yu, DapengX ; Yang, Qiming > ; Zhang, Qi Z > Cc: dev@dpdk.org; stable@dpdk.org > Subject: RE: [PATCH] net/ice: fix double free ACL flow entry >=20 >=20 >=20 > > -----Original Message----- > > From: Yu, DapengX > > Sent: Friday, September 3, 2021 6:04 PM > > To: Yang, Qiming ; Zhang, Qi Z > > > > Cc: dev@dpdk.org; Su, Simei ; Yu, DapengX > > ; stable@dpdk.org > > Subject: [PATCH] net/ice: fix double free ACL flow entry > > > > From: Dapeng Yu > > > > If call ice_flow_rem_entry() directly without checking entry_id, may > > cause an ACL flow entry to be freed more than once. > > > > This patch tries to find entry_id first, then call > > ice_flow_rem_entry() to avoid the defect. > > > > Fixes: 40d466fa9f76 ("net/ice: support ACL filter in DCF") > > Cc: stable@dpdk.org > > > > Signed-off-by: Dapeng Yu > > --- > > drivers/net/ice/ice_acl_filter.c | 33 > > +++++++++++++++++++++----------- > > 1 file changed, 22 insertions(+), 11 deletions(-) > > > > diff --git a/drivers/net/ice/ice_acl_filter.c > > b/drivers/net/ice/ice_acl_filter.c > > index 0c15a7036c..f44ce5d77e 100644 > > --- a/drivers/net/ice/ice_acl_filter.c > > +++ b/drivers/net/ice/ice_acl_filter.c > > @@ -45,7 +45,7 @@ static struct ice_flow_parser ice_acl_parser; > > > > struct acl_rule { > > enum ice_fltr_ptype flow_type; > > - uint32_t entry_id[4]; > > + uint64_t entry_id[4]; > > }; > > > > static struct > > @@ -440,7 +440,7 @@ ice_acl_hw_set_conf(struct ice_pf *pf, struct > > ice_fdir_fltr *input, > > PMD_DRV_LOG(ERR, "Fail to add entry."); > > return ret; > > } > > - rule->entry_id[entry_idx] =3D slot_id; > > + rule->entry_id[entry_idx] =3D entry_id; > > pf->acl.hw_entry_id[slot_id] =3D hw_entry; > > } else { > > PMD_DRV_LOG(ERR, "Exceed the maximum entry number(%d)" > > @@ -451,18 +451,28 @@ ice_acl_hw_set_conf(struct ice_pf *pf, struct > > ice_fdir_fltr *input, > > return 0; > > } > > > > +static inline void > > +ice_acl_del_entry(struct ice_hw *hw, uint64_t entry_id) { > > + uint64_t hw_entry; > > + > > + hw_entry =3D ice_flow_find_entry(hw, ICE_BLK_ACL, entry_id); > > + ice_flow_rem_entry(hw, ICE_BLK_ACL, hw_entry); } > > + > > static inline void > > ice_acl_hw_rem_conf(struct ice_pf *pf, struct acl_rule *rule, int32_t > > entry_idx) { > > uint32_t slot_id; > > int32_t i; > > + uint64_t entry_id; > > struct ice_hw *hw =3D ICE_PF_TO_HW(pf); > > > > for (i =3D 0; i < entry_idx; i++) { > > - slot_id =3D rule->entry_id[i]; > > + entry_id =3D rule->entry_id[i]; > > + slot_id =3D ICE_LO_DWORD(entry_id); > > rte_bitmap_set(pf->acl.slots, slot_id); > > - ice_flow_rem_entry(hw, ICE_BLK_ACL, > > - pf->acl.hw_entry_id[slot_id]); > > + ice_acl_del_entry(hw, entry_id); > > } > > } > > > > @@ -562,6 +572,7 @@ ice_acl_destroy_filter(struct ice_adapter *ad, { > > struct acl_rule *rule =3D (struct acl_rule *)flow->rule; > > uint32_t slot_id, i; > > + uint64_t entry_id; > > struct ice_pf *pf =3D &ad->pf; > > struct ice_hw *hw =3D ICE_PF_TO_HW(pf); > > int ret =3D 0; > > @@ -569,19 +580,19 @@ ice_acl_destroy_filter(struct ice_adapter *ad, > > switch (rule->flow_type) { > > case ICE_FLTR_PTYPE_NONF_IPV4_OTHER: > > for (i =3D 0; i < 4; i++) { > > - slot_id =3D rule->entry_id[i]; > > + entry_id =3D rule->entry_id[i]; > > + slot_id =3D ICE_LO_DWORD(entry_id); > > rte_bitmap_set(pf->acl.slots, slot_id); > > - ice_flow_rem_entry(hw, ICE_BLK_ACL, > > - pf->acl.hw_entry_id[slot_id]); > > + ice_acl_del_entry(hw, entry_id); > > } > > break; > > case ICE_FLTR_PTYPE_NONF_IPV4_UDP: > > case ICE_FLTR_PTYPE_NONF_IPV4_TCP: > > case ICE_FLTR_PTYPE_NONF_IPV4_SCTP: > > - slot_id =3D rule->entry_id[0]; > > + entry_id =3D rule->entry_id[0]; > > + slot_id =3D ICE_LO_DWORD(entry_id); > > rte_bitmap_set(pf->acl.slots, slot_id); > > - ice_flow_rem_entry(hw, ICE_BLK_ACL, > > - pf->acl.hw_entry_id[slot_id]); > > + ice_acl_del_entry(hw, entry_id); > > break; > > default: > > rte_flow_error_set(error, EINVAL, > > -- > > 2.27.0 >=20 > Reviewed-by: Simei Su >=20 Applied to dpdk-next-net-intel. Thanks Qi >=20