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 E2D61A00B8 for ; Mon, 28 Oct 2019 06:43:00 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B57B71BEF4; Mon, 28 Oct 2019 06:43:00 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 9C49E1BEF4; Mon, 28 Oct 2019 06:42:58 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Oct 2019 22:42:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,238,1569308400"; d="scan'208";a="193156264" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga008.jf.intel.com with ESMTP; 27 Oct 2019 22:42:57 -0700 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 27 Oct 2019 22:42:56 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 27 Oct 2019 22:42:56 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.213]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.2]) with mapi id 14.03.0439.000; Mon, 28 Oct 2019 13:42:54 +0800 From: "Yang, Qiming" To: "Jiang, JunyuX" , "dev@dpdk.org" CC: Chas Williams , "stable@dpdk.org" Thread-Topic: [PATCH] net/bonding: fix segfault using invalid port Thread-Index: AQHViuThhmsqij44m0ivUL/05k704advjuIA Date: Mon, 28 Oct 2019 05:42:53 +0000 Message-ID: References: <20191024205551.26273-1-junyux.jiang@intel.com> In-Reply-To: <20191024205551.26273-1-junyux.jiang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYWU4NGRjN2QtYWFjMi00YzM4LWFmMWQtN2Q3OWJlOWJjY2E4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiT1FvUUJ4Z1lRT3E4SXAwYzdoV2dwQlFpSm5ScHNad21XNytcL1ZyWUJubTNkSE1hRkpoXC96bGw2aXorWUpaSHQ2In0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-stable] [PATCH] net/bonding: fix segfault using invalid port X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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 Sender: "stable" Hi, Junyu > -----Original Message----- > From: Jiang, JunyuX > Sent: Friday, October 25, 2019 4:56 AM > To: dev@dpdk.org > Cc: Chas Williams ; Yang, Qiming ; > Jiang, JunyuX ; stable@dpdk.org > Subject: [PATCH] net/bonding: fix segfault using invalid port >=20 > Port validation should be prior to getting dev data to avoid segmentation > fault. This patch fixed the issue. >=20 > Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes") > Fixes: 112891cd27e5 ("net/bonding: add dedicated HW queues for LACP > control") > Cc: stable@dpdk.org >=20 > Signed-off-by: Jiang JunyuX > --- > drivers/net/bonding/rte_eth_bond_8023ad.c | 32 ++++++++++++++++------- > 1 file changed, 22 insertions(+), 10 deletions(-) >=20 > diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c > b/drivers/net/bonding/rte_eth_bond_8023ad.c > index 7d8da2b31..682854e39 100644 > --- a/drivers/net/bonding/rte_eth_bond_8023ad.c > +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c > @@ -1387,11 +1387,12 @@ > rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id, > struct bond_dev_private *internals; > struct mode8023ad_private *mode4; >=20 > + if (valid_bonded_port_id(port_id) !=3D 0) > + return -EINVAL; > + > bond_dev =3D &rte_eth_devices[port_id]; > internals =3D bond_dev->data->dev_private; >=20 > - if (valid_bonded_port_id(port_id) !=3D 0) > - return -EINVAL; > if (internals->mode !=3D 4) > return -EINVAL; >=20 > @@ -1408,11 +1409,12 @@ int > rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id) > struct bond_dev_private *internals; > struct mode8023ad_private *mode4; >=20 > + if (valid_bonded_port_id(port_id) !=3D 0) > + return -EINVAL; > + > bond_dev =3D &rte_eth_devices[port_id]; > internals =3D bond_dev->data->dev_private; >=20 > - if (valid_bonded_port_id(port_id) !=3D 0) > - return -EINVAL; > if (internals->mode !=3D 4) > return -EINVAL; > mode4 =3D &internals->mode4; > @@ -1665,9 +1667,14 @@ int > rte_eth_bond_8023ad_dedicated_queues_enable(uint16_t port) { > int retval =3D 0; > - struct rte_eth_dev *dev =3D &rte_eth_devices[port]; > - struct bond_dev_private *internals =3D (struct bond_dev_private *) > - dev->data->dev_private; > + struct rte_eth_dev *dev; > + struct bond_dev_private *internals; > + > + if (valid_bonded_port_id(port) !=3D 0) > + return -EINVAL; > + > + dev =3D &rte_eth_devices[port]; > + internals =3D dev->data->dev_private; Have you build success? I think we need to add (struct bond_dev_private *) = for force transfer >=20 > if (check_for_bonded_ethdev(dev) !=3D 0) > return -1; > @@ -1689,9 +1696,14 @@ int > rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port) { > int retval =3D 0; > - struct rte_eth_dev *dev =3D &rte_eth_devices[port]; > - struct bond_dev_private *internals =3D (struct bond_dev_private *) > - dev->data->dev_private; > + struct rte_eth_dev *dev; > + struct bond_dev_private *internals; > + > + if (valid_bonded_port_id(port) !=3D 0) > + return -EINVAL; > + > + dev =3D &rte_eth_devices[port]; > + internals =3D dev->data->dev_private; Same as before >=20 > if (check_for_bonded_ethdev(dev) !=3D 0) > return -1; > -- > 2.17.1