Message ID | 1519836450-11895-1-git-send-email-ophirmu@mellanox.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0BE864CB5; Wed, 28 Feb 2018 17:47:47 +0100 (CET) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0059.outbound.protection.outlook.com [104.47.2.59]) by dpdk.org (Postfix) with ESMTP id 016E94C97; Wed, 28 Feb 2018 17:47:45 +0100 (CET) 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=vIq1DucdqzvY9nLia1OsoVBtt1sjYm2fo2gQueHdOWs=; b=I1Zwf9iZqj/MrYnEdOBBwReo2pfMwIkotRCMvRS9pn9x6A9sYG1/K9ETUdspo+2db6c+pi7EIcm7ptw7ZIsncHOUprLCLibRL9sCtSp4orOnfH0x2xoxCAHyMXyC/1nRjDvQuclnTE8B6+ogtGeNXKJIyTpRySAyUWWbUaOnjJY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; Received: from mellanox.com (37.142.13.130) by HE1PR0502MB3882.eurprd05.prod.outlook.com (2603:10a6:7:87::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.527.15; Wed, 28 Feb 2018 16:47:43 +0000 From: Ophir Munk <ophirmu@mellanox.com> To: dev@dpdk.org, Adrien Mazarguil <adrien.mazarguil@6wind.com> Cc: Thomas Monjalon <thomas@monjalon.net>, Olga Shern <olgas@mellanox.com>, Ophir Munk <ophirmu@mellanox.com>, stable@dpdk.org Date: Wed, 28 Feb 2018 16:47:30 +0000 Message-Id: <1519836450-11895-1-git-send-email-ophirmu@mellanox.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1P194CA0048.EURP194.PROD.OUTLOOK.COM (2603:10a6:803:3c::37) To HE1PR0502MB3882.eurprd05.prod.outlook.com (2603:10a6:7:87::25) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1d073c1b-cfae-487c-ff85-08d57ecafd6b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:HE1PR0502MB3882; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0502MB3882; 3:ZH5ycT0FYyjqqRQXGjTasJFsheixehUjtY98HaXYmpwy+JT5PIP8j1L/Rpq5WjDmahcQmqaNIbrQuANkfVPTIyEdL5P4UMJf1mdbwgqwayvndsB+6v4BA6hOYTbjHcBx2bY21PSJcHUBhM28/KjQFQ+Wybdl6eCAuem1daU29CVVNiTAClUnUcZC8GbGoH70265O+QnJIWt7LlD0L7JFPcm0aIpQMv3j77H45zUpZuFzlFY+MZ0Vap3QBehrFyFH; 25:ymluiLPS0XLIREMc0KheywJMEy9GTnuzlDBf0tFulYaPwYnWN1HvChdptrgLpvABH5/53nC//MYGBPq9lm4VRLJofrIaRugvf77lNANlFmd96GNZGjoVupKEzfZh19Fm8JkS2v8X5UJRYpd39McuFszrhafCD9XFfcZygwScN9MI8QOGcTR8wirwlq68ZgDaMlBEefagBhzoeAJhSpTeXh7xOZ4Afeuu1aiedwp1v09G2T+XywUq3LCfMKDXLw/7W5P8F+PS6HTFV2k/Ob8edsYQIf8uEGcMtthsymvuj5a7j9pB4T25j/wTpamIxe8sfDcLR82PdOhz2SSJl2J57w==; 31:2JdSo4F+oQvPwhCI7EwyQuI81KJRamP42SX5EzoWBs1Dtr2uzPrpl6iqJkoAYH+gK7w2lo7a+t8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X-Microsoft-Antispam-PRVS: <HE1PR0502MB3882C955ED76D114BB9373FAD1C70@HE1PR0502MB3882.eurprd05.prod.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040501)(2401047)(8121501046)(5005006)(3002001)(3231220)(944501217)(52105095)(93006095)(93001095)(10201501046)(6055026)(6041288)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:HE1PR0502MB3882; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0502MB3882; X-Forefront-PRVS: 0597911EE1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(366004)(376002)(396003)(39860400002)(39380400002)(189003)(199004)(50226002)(66066001)(8676002)(81166006)(7736002)(25786009)(4326008)(6916009)(478600001)(5660300001)(47776003)(4720700003)(2906002)(53936002)(305945005)(6666003)(16526019)(26005)(55016002)(8936002)(69596002)(21086003)(48376002)(7696005)(52116002)(50466002)(6116002)(33026002)(186003)(16586007)(386003)(97736004)(54906003)(105586002)(59450400001)(51416003)(316002)(106356001)(36756003)(3846002)(81156014)(86362001)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0502MB3882; H:mellanox.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) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0502MB3882; 23:v4xcJKfmrrJ9Gj2lCQF0zNdgF+JmjALaDPeJRKv?= avyF5p4/tyR5lKVs4/V1oVe2APJ1SupOxP0AIdg8dz/DGX2erFYhpxVmXdqv6+sqhcLx7ih+garKE0s/G7jL8n+lszzwi1B4vUWXvilmFMp36FzqvAfimftEN1dpZxkfghvloXvCEVpNmZBP0hQzsiFsGatg6jwQTjk/Do85ABOzFO2fMKKYubgY+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D0/H7XaYqXeuWiQJlahL5O5/81ZFcZ/h00YdkYcYUyskfU1A+BwhzgfHjSpXt/rxKE2gARr/6p1zOADvzisG8nJLknJjn366UxPbJ6xc/RbjE0soUHelk9KWtFL9ABg/F7qKF1aKKlNPH/PX2AfykwTwgKsZmiE4PAmgtbGM+pioX3/IZIGz0lm4gnxrZ3uXhRz2buwpXox3SrIPnSWynGwTGIrL/5Zymj+YTZAETPC0moZHC41rykpMZIdCShMzc+ioLXVedObfuYwxdB6rVezs71BUWph26clA=; 5:P97vAt73gleJPiNQUYEioinTAYnDqj0NSPEvEsB0RWRS+w+WbfJgNQ7WRtTXcC0RsAVcgUFjhSPgV2Tm3xXtbLxXVCpH1CA+GHBG8M6j99ePjecUQ32b//GjaRSHxl8qrzdNXD6uc6n/sk9Uq6MLFcGksIqEcBD3l1jjgcfZv4M=; 24:rZaF/QjM79xicKGVVi/YbddROxAJK4Hg09UsBOPqCnzC4DVGJl4e1yKs4gtstYy6V9CYt+alAFII/CJ2Yb5XI1CgHRwgI7+Otko/b19DSoc=; 7:6sM3yYPqY/FC3SQKkcxGDOllwXvVgFvni8bI56+JJddd7mHWAttnnUddTgauadlgI/dXDjKlKpPRawk8+7VSjwspcpfOZzVyWvI22I1Y2+JoJp/9IPAU2CUPrRkJl6EYCeR+EzGAJfgiT7VZliFglNlEQqnEM4WlXuBReZeHA6NtNpnBbLf5eGYviaYnh3jQO55KNq+qxzygDUNpKwQ4F4FPljxB0n+F5ynVCwmk/hSDEl+HMyrVeakR8mBPuCcN SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2018 16:47:43.1125 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1d073c1b-cfae-487c-ff85-08d57ecafd6b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0502MB3882 Subject: [dpdk-dev] [PATCH v1] net/mlx4: fix 'show port info all' during detach X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions <dev.dpdk.org> List-Unsubscribe: <https://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <https://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Checks
Context | Check | Description |
---|---|---|
ci/checkpatch | success | coding style OK |
ci/Intel-compilation | success | Compilation OK |
Commit Message
Ophir Munk
Feb. 28, 2018, 4:47 p.m. UTC
The following scenario causes a crash in function mlx4_get_ifname
1. On testpmd startup mlx4 device is probed and started
2. mlx4 sriov is disabled. As a result an RMV event is sent to
testpmd which closes the device and nullify the priv struct
members.
3. Running 'show port info all' in testpmd results in segmentation
fault because of accessing NULL pointer priv->ctx
The fix is to return with an error from mlx4_get_ifname() if priv->ctx
member is NULL.
Fixes: 61cbdd419478 ("net/mlx4: separate device control functions")
Cc: stable@dpdk.org
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
drivers/net/mlx4/mlx4_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On Wed, Feb 28, 2018 at 04:47:30PM +0000, Ophir Munk wrote: > The following scenario causes a crash in function mlx4_get_ifname > 1. On testpmd startup mlx4 device is probed and started > 2. mlx4 sriov is disabled. As a result an RMV event is sent to > testpmd which closes the device and nullify the priv struct > members. > 3. Running 'show port info all' in testpmd results in segmentation > fault because of accessing NULL pointer priv->ctx > > The fix is to return with an error from mlx4_get_ifname() if priv->ctx > member is NULL. So priv->ctx is NULL after mlx4_dev_close() was called. In my opinion the fact testpmd is allowed to call rte_eth_dev_info_get() on a closed port is fishy, there are quite a few other ethdev callbacks that may end up crashing in such a scenario. Since commit 284c908cc588 ("app/testpmd: request device removal interrupt"), testpmd automatically calls rte_eth_dev_close() and rte_eal_dev_detach() after receiving a removal event on a port. rte_eth_dev_close() documentation says: "Close a stopped Ethernet device. The device cannot be restarted! The function frees all resources except for needed by the closed state. To free these resources, call rte_eth_dev_detach()." Unfortunately testpmd calls rte_*eal*_dev_detach() not rte_*eth*_dev_detach(), the former doesn't release ethdev ports while the latter does. I think it's a mistake, there's no point in keeping a closed device around after it's been physically unplugged. In short, rmv_event_callback() should call detach_port() instead of rte_eal_dev_detach(). > Fixes: 61cbdd419478 ("net/mlx4: separate device control functions") > Cc: stable@dpdk.org > > Signed-off-by: Ophir Munk <ophirmu@mellanox.com> The above suggests the problem is actually in testpmd and was introduced in v17.05 by commit 284c908cc588. The proposed patch is a workaround that doesn't address the underlying issue, thus NACK unless proven otherwise :) > --- > drivers/net/mlx4/mlx4_ethdev.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c > index 3bc6927..cca5223 100644 > --- a/drivers/net/mlx4/mlx4_ethdev.c > +++ b/drivers/net/mlx4/mlx4_ethdev.c > @@ -67,6 +67,9 @@ mlx4_get_ifname(const struct priv *priv, char (*ifname)[IF_NAMESIZE]) > char match[IF_NAMESIZE] = ""; > > { > + if (priv->ctx == NULL) > + return -ENOENT; > + > MKSTR(path, "%s/device/net", priv->ctx->device->ibdev_path); > > dir = opendir(path); > -- > 2.7.4 >
Hi Ophir, Adrien, On Fri, Mar 02, 2018 at 08:12:58PM +0100, Adrien Mazarguil wrote: > On Wed, Feb 28, 2018 at 04:47:30PM +0000, Ophir Munk wrote: > > The following scenario causes a crash in function mlx4_get_ifname > > 1. On testpmd startup mlx4 device is probed and started > > 2. mlx4 sriov is disabled. As a result an RMV event is sent to > > testpmd which closes the device and nullify the priv struct > > members. > > 3. Running 'show port info all' in testpmd results in segmentation > > fault because of accessing NULL pointer priv->ctx > > > > The fix is to return with an error from mlx4_get_ifname() if priv->ctx > > member is NULL. > > So priv->ctx is NULL after mlx4_dev_close() was called. In my opinion the > fact testpmd is allowed to call rte_eth_dev_info_get() on a closed port is > fishy, there are quite a few other ethdev callbacks that may end up > crashing in such a scenario. > > Since commit 284c908cc588 ("app/testpmd: request device removal interrupt"), > testpmd automatically calls rte_eth_dev_close() and rte_eal_dev_detach() > after receiving a removal event on a port. > > rte_eth_dev_close() documentation says: > > "Close a stopped Ethernet device. The device cannot be restarted! > The function frees all resources except for needed by the > closed state. To free these resources, call rte_eth_dev_detach()." > > Unfortunately testpmd calls rte_*eal*_dev_detach() not > rte_*eth*_dev_detach(), the former doesn't release ethdev ports while the > latter does. I think it's a mistake, there's no point in keeping a closed > device around after it's been physically unplugged. > > In short, rmv_event_callback() should call detach_port() instead of > rte_eal_dev_detach(). > This is correct, the issue is actually testpmd making a mistake when calling directly rte_eal_dev_detach(). The fix should thus be simply to change this call. > > Fixes: 61cbdd419478 ("net/mlx4: separate device control functions") > > Cc: stable@dpdk.org > > > > Signed-off-by: Ophir Munk <ophirmu@mellanox.com> > > The above suggests the problem is actually in testpmd and was introduced in > v17.05 by commit 284c908cc588. The proposed patch is a workaround that > doesn't address the underlying issue, thus NACK unless proven otherwise :) > > > --- > > drivers/net/mlx4/mlx4_ethdev.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c > > index 3bc6927..cca5223 100644 > > --- a/drivers/net/mlx4/mlx4_ethdev.c > > +++ b/drivers/net/mlx4/mlx4_ethdev.c > > @@ -67,6 +67,9 @@ mlx4_get_ifname(const struct priv *priv, char (*ifname)[IF_NAMESIZE]) > > char match[IF_NAMESIZE] = ""; > > > > { > > + if (priv->ctx == NULL) > > + return -ENOENT; > > + > > MKSTR(path, "%s/device/net", priv->ctx->device->ibdev_path); > > > > dir = opendir(path); > > -- > > 2.7.4 > > > > -- > Adrien Mazarguil > 6WIND
diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index 3bc6927..cca5223 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -67,6 +67,9 @@ mlx4_get_ifname(const struct priv *priv, char (*ifname)[IF_NAMESIZE]) char match[IF_NAMESIZE] = ""; { + if (priv->ctx == NULL) + return -ENOENT; + MKSTR(path, "%s/device/net", priv->ctx->device->ibdev_path); dir = opendir(path);