From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0087.outbound.protection.outlook.com [104.47.0.87]) by dpdk.org (Postfix) with ESMTP id 13BBD532C; Wed, 26 Jul 2017 11:21:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/XciOH07+UCI1TMPXC729d7SkJ5hf4CXQCENan5Qz3M=; b=UskOpLfL7k2HeR+jwmLk0tuW3we1aRdwXrCXrrT8aUdePY1k4tP0bnBcT0gIwZAv5ep5HtXHq4Gb4N6X+hKRZNX3k3YV9+j2naVbIuZmGCpmuggA+Q+aPQyYG4fwNmBj8SgCOjF7JjFz2MUERs3NJDm+WD5pNe3ZpqgMzlNKssI= Received: from AM2PR05MB0689.eurprd05.prod.outlook.com (10.161.20.16) by AM4PR05MB3140.eurprd05.prod.outlook.com (10.171.186.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1282.10; Wed, 26 Jul 2017 09:21:27 +0000 Received: from AM2PR05MB0689.eurprd05.prod.outlook.com ([fe80::dd84:1887:d148:89ab]) by AM2PR05MB0689.eurprd05.prod.outlook.com ([fe80::dd84:1887:d148:89ab%15]) with mapi id 15.01.1282.017; Wed, 26 Jul 2017 09:21:27 +0000 From: Shachar Beiser To: Adrien Mazarguil CC: "dev@dpdk.org" , =?iso-8859-1?Q?N=E9lio_Laranjeiro?= , "stable@dpdk.org" , "Shahaf Shuler" Thread-Topic: [PATCH] net/mlx5: fix verification of device context Thread-Index: AQHTBdJLMRkLRPqDaUCVKatWXY878qJl0TeAgAADwwA= Date: Wed, 26 Jul 2017 09:21:27 +0000 Message-ID: References: <5ec0604196fb087a42fa75e6ddc2a04aab293593.1501047767.git.shacharbe@mellanox.com> <20170726090613.GT19852@6wind.com> In-Reply-To: <20170726090613.GT19852@6wind.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=shacharbe@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR05MB3140; 7:9AttVSjuJcku8NmitIDfgqZMuPqyInLjIegdtUmuRGCmYmuc52TsIq4YQ/iyuleTg+0LzW186HGUGWvmrd5798Hn9sP9cIJmr3HMU0MDALmYQlcADTqRarSuD6rzTLjQm+Rb3XLC1kjlKMvy791x/zG8qF7OC+mhOBJv+loVRxqmT9qHxEfJksUcftDqxbZQgwlq/euHdQyH24MGLNQgbdFLMlpoNzie7uYGxjlE/jWfuXisMh6vuH3N61nU0zyvdTdrqK05sv5YCrKX2DOy6/4+eJgWSGAPKTBcDX7beBrfqCrigSylaHyojSnzIK8yLmPvmYJWT8+N0N/tlcN8HAB4TcA+YXerX65DGwadVhILA+0ROOPZD8Pw0JKYWj4fODbmtJGg6CQE20iYMeym3JCBjQeSJh3W9tHffOLYBehjxYtkvKltT7li3lj4g37iOKc9KU2lI3xVMwpUoXTOmWxPXbsZSU4y3dYace6YETbjgK3t2s95W0Q6Pr335rbFpVyTkoAGwuS9QFrlCU5bNe1t+0lz9UAOpak0nNHRwwEQyujZ9R7vtB29YuIgSYZ223DfHY8nvhLA6VRHCfleq5inGpBAnz/wkr+sF1SZPnWg0/5HpSnPkssvEWrrL3Fr6+26WwI4wm3lKQYLtGC9eMDbwdVVv3bibmr6Mcl8tyHVhK07Oomc4kCHBio2b/NyLb49tx1FRjvowtEWkCumszKIQ5aie9/6AIJXs2AT5U4r+/8jFDKxmjDyWu+V13Wgprhtqr/ZygAvSPa4jog0qk6U9k/l/HBtvRoLLhi3EZE= x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-ms-office365-filtering-correlation-id: 1cbdd7d0-95f7-46a1-16c2-08d4d407b182 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(300000503095)(300135400095)(48565401081)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:AM4PR05MB3140; x-ms-traffictypediagnostic: AM4PR05MB3140: x-exchange-antispam-report-test: UriScan:(278428928389397); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123562025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM4PR05MB3140; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM4PR05MB3140; x-forefront-prvs: 038002787A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39410400002)(39850400002)(39400400002)(39840400002)(39860400002)(39450400003)(13464003)(24454002)(189002)(377454003)(199003)(54906002)(14454004)(55016002)(99286003)(97736004)(8936002)(81156014)(8676002)(81166006)(74316002)(6436002)(305945005)(5250100002)(9686003)(7736002)(6116002)(102836003)(3846002)(2900100001)(5660300001)(53546010)(68736007)(229853002)(2950100002)(478600001)(25786009)(6916009)(7696004)(53936002)(38730400002)(107886003)(50986999)(189998001)(6506006)(6246003)(3280700002)(105586002)(54356999)(110136004)(101416001)(4326008)(33656002)(86362001)(106356001)(76176999)(2906002)(15650500001)(3660700001)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3140; H:AM2PR05MB0689.eurprd05.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jul 2017 09:21:27.1534 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3140 Subject: Re: [dpdk-dev] [PATCH] net/mlx5: fix verification of device context 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: , X-List-Received-Date: Wed, 26 Jul 2017 09:21:29 -0000 Hi , When I say close I mean : " mlx5_dev_close" . This function set the = priv->ctx to NULL. We think this patch is required because we have an open bug of seg f= ault while accessing priv->ctx =3D=3D NULL. -Shachar Beiser.=20 =20 -----Original Message----- From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com]=20 Sent: Wednesday, July 26, 2017 12:06 PM To: Shachar Beiser Cc: dev@dpdk.org; N=E9lio Laranjeiro ; stable@d= pdk.org Subject: Re: [PATCH] net/mlx5: fix verification of device context Hi Shachar, On Wed, Jul 26, 2017 at 05:43:24AM +0000, Shachar Beiser wrote: > Get interface name function lacks verification of device context. > It might lead to segmentation fault when trying to query the name=20 > after the device is closed.fixing it by adding the missing=20 > verification >=20 Thanks, however if by "close" you mean it may occur when applications use e= thdev callbacks after a call to rte_eth_dev_close(), I do not think PMDs ha= ve to protect themselves against bad application behavior, otherwise there = is no end to such fixes. The reverse of rte_eth_dev_close() is not rte_eth_dev_configure() nor any o= ther ethdev callback (see documentation), but a bus probe operation. Perhaps I've missed something, so in case a crash occurs *while* calling rte_eth_dev_close() I guess this patch is fine, but then please describe th= e reason. > Fixes: cd89f22a1e9770 ("net/mlx5: remove unused interface name query") This commit doesn't look like the root cause of that issue? > Cc: stable@dpdk.org >=20 > Signed-off-by: Shachar Beiser > --- > drivers/net/mlx5/mlx5_ethdev.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/drivers/net/mlx5/mlx5_ethdev.c=20 > b/drivers/net/mlx5/mlx5_ethdev.c index b70b7b9..6e67461 100644 > --- a/drivers/net/mlx5/mlx5_ethdev.c > +++ b/drivers/net/mlx5/mlx5_ethdev.c > @@ -173,6 +173,10 @@ struct priv * > char match[IF_NAMESIZE] =3D ""; > =20 > { > + if (priv->ctx =3D=3D NULL) { > + DEBUG("The device is closed, cannot query interface name "); > + return -1; > + } MKSTR() is at the beginning of this block because it defines a new variable= (path). For coding style consistency you should not put any code before va= riable declarations, or at least insert an empty line between them. Otherwi= se you could move this check to the parent block. > MKSTR(path, "%s/device/net", priv->ctx->device->ibdev_path); > =20 > dir =3D opendir(path); > -- > 1.8.3.1 >=20 I think this patch is not necessary unless proved otherwise, have you actually observed a crash addressed by it? --=20 Adrien Mazarguil 6WIND