From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 68AC4A0093; Fri, 22 May 2020 05:43:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C960E1D8CC; Fri, 22 May 2020 05:43:58 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 595061D736 for ; Fri, 22 May 2020 05:43:57 +0200 (CEST) IronPort-SDR: 7rzsvSuRSX2PrrvPtNG7YXQupk84K6bobP6W6amryWtebmOvm4Q4ONCMuKpxOCDi/Pw6gGZ9WH XFmG6YW9zwEA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2020 20:43:56 -0700 IronPort-SDR: 5U2iSrOyVqYABi6/kVRMFMlYaXrqe48HaBV09FPzQilrKcnDiNX+ji46hO4UgjLkTP3WUxAbuo Bvumxitn7cRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,420,1583222400"; d="scan'208";a="254199354" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga007.jf.intel.com with ESMTP; 21 May 2020 20:43:56 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 21 May 2020 20:43:55 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 21 May 2020 20:43:55 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 21 May 2020 20:43:55 -0700 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (104.47.38.51) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 21 May 2020 20:43:55 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KUTSb0pNHfzRa1a4r9F0J5ncCiOjtH9EwTSpouhiJT3jys/ntRpv/pACLMqAnCmUCgXZYQrl2UEQ0fQeFjhO9XizUXlpAoZ/zc5Qs0+RWbsxsVm6o1t9gi/UCd1rOXwj+vswQ6Sdf4yL9nrpXlf97yDpbi6Ei1ndj5pKZMcl0nzPvbIIez7oX/sk+KxBg0X/m6ZZwMgeBJS/xNfN20y393aPxEQadtWedTA5Xrv53XP4fqf8lGdGBGzwiQZMt4bkyrMzmJsobodidjap730V/xWOT8tjqQzIgL1AKD5e2BdJ99YUIQ76CgTshao89K0/6eGLstwHB2hF8DSPbNzjAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oLW9/fHa4fdTKx+wOxk+FVtFaEtZLvVsAjE1Veosmc4=; b=jCoJEmSiSNlorN+nLi85D7sS6RxNemoCRz6ECja7ZTP8uSV4hlxEBrRnhU88S+zIkEsqh4u/KZFOoKWGnqwXX/VDYPr91a7c+GeDmhVwicVetQ9AUY8+IUCZabY1/91k93OnMhbaLn20m+ymQ1mDPu/jsd6tQ6ohq10pUZfQdQNf3khw9IRsF/NLFdGhdDYk4dJ4nibSIbf2ytmxIL+rEecTFpplJGLAPEgZoiT4QoalX+TKGzlkfo9zU6/SJJKbk+JNHNFUe2m5b4/g9EfcskG8bSFs5n4TohvcmYFx8vKgzw0cMdNQSKSBSGNaZ+qigp5Wud7LKth2n+d1rCRGUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oLW9/fHa4fdTKx+wOxk+FVtFaEtZLvVsAjE1Veosmc4=; b=THjJIrb//QAAP/s8sdCUBr7uHuF5K9k0ZvaZwu5pRtpET4PUWhubV1guel1I6P3/jMI8XdkaL7P/b30acXwZMtrX6guNFeKzxWWB/JyUxexas/eTkpSR0lYlV7t/Kmpu7SoR6f6ZLZE2JTXOt9W4NPjtIqhGxgkVlSTRB3oNPNE= Received: from BY5PR11MB3893.namprd11.prod.outlook.com (2603:10b6:a03:183::26) by BY5PR11MB4451.namprd11.prod.outlook.com (2603:10b6:a03:1cb::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23; Fri, 22 May 2020 03:43:52 +0000 Received: from BY5PR11MB3893.namprd11.prod.outlook.com ([fe80::65ec:b3c9:7f24:d067]) by BY5PR11MB3893.namprd11.prod.outlook.com ([fe80::65ec:b3c9:7f24:d067%6]) with mapi id 15.20.3021.024; Fri, 22 May 2020 03:43:51 +0000 From: "Peng, Yuan" To: "Guo, Jia" , "Xing, Beilei" , "Zhang, Qi Z" , "Wu, Jingjing" , "Yang, Qiming" CC: "Ye, Xiaolong" , "dev@dpdk.org" , "Guo, Jia" Thread-Topic: [dpdk-dev] net/iavf: fix invalid flow access Thread-Index: AQHWL3n939Zzhi4gcEOXVF3o5VhJTqizd1bA Date: Fri, 22 May 2020 03:43:51 +0000 Message-ID: References: <20200522021151.55835-1-jia.guo@intel.com> In-Reply-To: <20200522021151.55835-1-jia.guo@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.52.219] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 84a11f42-1c82-44f4-cffc-08d7fe025839 x-ms-traffictypediagnostic: BY5PR11MB4451: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1284; x-forefront-prvs: 04111BAC64 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qa6+6xoPS1R4a/cib+OXbDIKvN8b2mML9epbNQnurxeg05s8qsGsBLYu2B4X43WzWy2iFU6CZ58W4FRHKXaYH/EoOCPM+Ep+BZeLTMmhju4zOYYOF0DuNqz5HljqE0DMZ85pFOINB9S5Pf+59tyI2iwyHETzHik0IUHh57teUssKMxL59bxl8yjMaP5FFT7ZW8Up35XWK2zzckx3DDXt8kREOolElIsspqcgSpvT8XMaJj6WZ7C432D0oWlmlDGqNUV/o9nGoHVBirp64wrljJ8nHb8g9YTFyWZ9jkbsWlQLA1lTfuhbVFBSKgOn6zZnANm/01PyhssRPZCSOPbbWZ/bwkNT4MfwzvbzG2u92OpkX6K0GXUxBdvzHlfYFZa/ x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR11MB3893.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(346002)(366004)(376002)(396003)(39860400002)(136003)(52536014)(66476007)(33656002)(316002)(64756008)(76116006)(66556008)(6636002)(66446008)(55016002)(9686003)(53546011)(2906002)(107886003)(186003)(6506007)(7696005)(4326008)(5660300002)(110136005)(26005)(54906003)(71200400001)(66946007)(8936002)(8676002)(86362001)(478600001)(921003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: cUbMvoFx9VUV4cv2NcCHHgyb90E2dn1VBaTJePd/Wr4pZ17h/lXAHkVe2k19BbRVLqdd6E1ZR08J2XN4Oj4b3qEfVvy6DXtz4yJanc6U0S73YZ1Qp6egPta0Q9+Mzlqw2ce45d9g2FQZAgoUAkxd1G1ZruTCdGbMtRRTpWoHJKK+90hgBueMz89BDeCadi17/d84Z67Y+RiolhK/owNopmlDCPmTzOf5j/iC8fVhMGg89pBbBl4ZrEboNBWIK9pkpwxgTEZKw6yQdvOldBsnLBCEseXkv0uVgEbjlVELJsa9t0v+GVpXMEoQrLHj1Xr7PHsCV2YMWHX0vnOayej0gpda8m8KeFFQ/XcB0uqNCmy3F1DNyLtupzm6WnqkGROUojyhbd5s/EEsiKliQAKMSn+yxvrxYV6h2eFurvJXvZKpXngDJPE199nJUS6B53IgypjHGftemStsqJnzFKg0saFUF8igLCNmSi9igg0L3633XEAplbNkDyg0dkqcu8kg Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 84a11f42-1c82-44f4-cffc-08d7fe025839 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 May 2020 03:43:51.7609 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: SU4yeAM2ExZJLF//2NDyeqeyqfdE7XYtmNoL13kGq5VCO2AAqe+iK5P3WmUAvI5epFibdSi7krhp0UynlhKBhA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4451 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] net/iavf: fix invalid flow access X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Test-by Peng, Yuan -----Original Message----- From: dev On Behalf Of Jeff Guo Sent: Friday, May 22, 2020 10:12 AM To: Xing, Beilei ; Zhang, Qi Z ; Wu, Jingjing ; Yang, Qiming Cc: Ye, Xiaolong ; dev@dpdk.org; Guo, Jia Subject: [dpdk-dev] net/iavf: fix invalid flow access When hash init, the default rss rules would be added, while hash uninit, th= e default rss rules should be deleted. Add the missing part in the hash uni= nit process. Also add invalid flow checking func in iavf generic flow to av= oid the error of "Cannot access memory at address 0xXXXXXX" occur. Fixes: 5ea614254332 ("net/iavf: fix VF reset for RSS") Fixes: ff2d0c345c3b ("net/iavf: support generic flow API") Signed-off-by: Jeff Guo --- drivers/net/iavf/iavf_generic_flow.c | 24 ++++++++++++++++++++---- drivers/net/iavf/iavf_hash.c | 12 ++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/net/iavf/iavf_generic_flow.c b/drivers/net/iavf/iavf_g= eneric_flow.c index c0c67d0c7..b6c26c4fd 100644 --- a/drivers/net/iavf/iavf_generic_flow.c +++ b/drivers/net/iavf/iavf_generic_flow.c @@ -935,6 +935,22 @@ iavf_flow_create(struct rte_eth_dev *dev, return flow; } =20 +static bool +iavf_flow_is_valid(struct rte_flow *flow) { + struct iavf_flow_engine *engine; + void *temp; + + if (flow && flow->engine) { + TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) { + if (engine =3D=3D flow->engine) + return true; + } + } + + return false; +} + static int iavf_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, @@ -945,10 +961,10 @@ iavf_flow_destroy(struct rte_eth_dev *dev, struct iavf_info *vf =3D IAVF_DEV_PRIVATE_TO_VF(ad); int ret =3D 0; =20 - if (!flow || !flow->engine || !flow->engine->destroy) { + if (!iavf_flow_is_valid(flow) || !flow->engine->destroy) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_HANDLE, - NULL, "Invalid flow"); + NULL, "Invalid flow destroy"); return -rte_errno; } =20 @@ -1002,10 +1018,10 @@ iavf_flow_query(struct rte_eth_dev *dev, IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct rte_flow_query_count *count =3D data; =20 - if (!flow || !flow->engine || !flow->engine->query_count) { + if (!iavf_flow_is_valid(flow) || !flow->engine->query_count) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_HANDLE, - NULL, "Invalid flow"); + NULL, "Invalid flow query"); return -rte_errno; } =20 diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c in= dex 56ab170d8..af528863b 100644 --- a/drivers/net/iavf/iavf_hash.c +++ b/drivers/net/iavf/iavf_hash.c @@ -887,7 +887,7 @@ static struct iavf_flow_parser iavf_hash_parser =3D { = }; =20 static int -iavf_hash_default_set(struct iavf_adapter *ad) +iavf_hash_default_set(struct iavf_adapter *ad, bool add) { struct virtchnl_rss_cfg *rss_cfg; uint16_t i; @@ -902,9 +902,10 @@ iavf_hash_default_set(struct iavf_adapter *ad) rss_cfg->proto_hdrs =3D *iavf_hash_default_hdrs[i]; rss_cfg->rss_algorithm =3D VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC; =20 - ret =3D iavf_add_del_rss_cfg(ad, rss_cfg, true); + ret =3D iavf_add_del_rss_cfg(ad, rss_cfg, add); if (ret) { - PMD_DRV_LOG(ERR, "fail to add RSS configure"); + PMD_DRV_LOG(ERR, "fail to %s RSS configure", + add ? "add" : "delete"); rte_free(rss_cfg); return ret; } @@ -941,7 +942,7 @@ iavf_hash_init(struct iavf_adapter *ad) return ret; } =20 - ret =3D iavf_hash_default_set(ad); + ret =3D iavf_hash_default_set(ad, true); if (ret) { PMD_DRV_LOG(ERR, "fail to set default RSS"); iavf_unregister_parser(parser, ad); @@ -1222,6 +1223,9 @@ iavf_hash_destroy(__rte_unused struct iavf_adapter *a= d, static void iavf_hash_uninit(struct iavf_adapter *ad) { + if (iavf_hash_default_set(ad, false)) + PMD_DRV_LOG(ERR, "fail to delete default RSS"); + iavf_unregister_parser(&iavf_hash_parser, ad); } =20 -- 2.20.1