From patchwork Tue Dec 1 18:17:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 7739571 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BFC079F30B for ; Tue, 1 Dec 2015 18:17:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8CC1420534 for ; Tue, 1 Dec 2015 18:17:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 43CD720452 for ; Tue, 1 Dec 2015 18:17:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932081AbbLASRn (ORCPT ); Tue, 1 Dec 2015 13:17:43 -0500 Received: from mail-bn1on0093.outbound.protection.outlook.com ([157.56.110.93]:20548 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932079AbbLASRl (ORCPT ); Tue, 1 Dec 2015 13:17:41 -0500 Received: from CY1PR0201CA0001.namprd02.prod.outlook.com (10.163.30.139) by DM2PR02MB301.namprd02.prod.outlook.com (10.141.83.140) with Microsoft SMTP Server (TLS) id 15.1.331.20; Tue, 1 Dec 2015 18:17:39 +0000 Received: from BL2FFO11FD017.protection.gbl (2a01:111:f400:7c09::140) by CY1PR0201CA0001.outlook.office365.com (2a01:111:e400:58b9::11) with Microsoft SMTP Server (TLS) id 15.1.337.19 via Frontend Transport; Tue, 1 Dec 2015 18:17:39 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.173) smtp.mailfrom=sandisk.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.173 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.173; helo=milsmgep12.sandisk.com; Received: from milsmgep12.sandisk.com (63.163.107.173) by BL2FFO11FD017.mail.protection.outlook.com (10.173.161.35) with Microsoft SMTP Server id 15.1.331.11 via Frontend Transport; Tue, 1 Dec 2015 18:17:37 +0000 Received: from MILHUBIP03.sdcorp.global.sandisk.com ( [172.22.12.162]) by milsmgep12.sandisk.com (Symantec Messaging Gateway) with SMTP id 6C.6F.32178.C34ED565; Tue, 1 Dec 2015 10:17:32 -0800 (PST) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.248.2; Tue, 1 Dec 2015 10:17:33 -0800 X-AuditID: ac160a69-f79f76d000007db2-38-565de43ca075 Received: from [10.60.52.33] ( [10.177.8.100]) by milsmgip11.sandisk.com (Symantec Messaging Gateway) with SMTP id 41.86.15370.C34ED565; Tue, 1 Dec 2015 10:17:32 -0800 (PST) Subject: [PATCH 1/6] IB/srp: Fix a memory leak To: Doug Ledford References: <565DE3EC.2070002@sandisk.com> CC: Sagi Grimberg , Christoph Hellwig , Sebastian Parschauer , "linux-rdma@vger.kernel.org" From: Bart Van Assche Message-ID: <565DE43C.6040805@sandisk.com> Date: Tue, 1 Dec 2015 10:17:32 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <565DE3EC.2070002@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgkeLIzCtJLcpLzFFi42JZI8azSNfmSWyYwbej5hYvz39gtTg9YRGT xbNDvSwWr48/ZbI4eZvfgdVj+oxNrB6bV2h5/Pnzmdnj/b6rbB6fN8kFsEZx2aSk5mSWpRbp 2yVwZSw9fY2l4Kx0Rc/uC2wNjH9Fuxg5O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wwN9YoT81Iyi7P1kvNzNzGCA5czcgfj 04nmhxiZODilGhhtBMqld/1efKv0iFCUHbf0Og3DWC7Ov7633mT5ftumkLJv5bzJdo++76hn e/qxaKXfg3o/+/C7cR/01a2Orz3+W5Hnw07tXyeu3FnlfE/99M2Jc9rbLpyO0j65QoSzY9lL kaIJn7tczlmv+53xxnvZ51lTPleKdvhGRju/YtFO+deYx7bIa/5PJZbijERDLeai4kQAmK0S DgwCAAA= X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD017; 1:gq0p/y/64GLkrA4pccYH2ufyeWp5QF9j56jTPD5FlXNuR3ee0qMAgj2PFakq8X8erfBzHnGW//UFWTmdamPEcTBU6CDTnTALCg6egysHvmRAStMgK4PCb7vLNYlePeIDPu97y0wSATMmHxe91cA0dwViIgFHvywMUBQHCCn2iPsOPcc6eSxgzYCpt4DgNj8RNWdcegki+7Dbnif55HDihCJMDSEgjlS8j99T1mNCjJxgFjBRI/SgTSO7qgaOqhoF0vRznWc2SPDd3E0NODL7OmzKKAMLnc9FfoXt5bf9OYCPatIZoGmwFcc+wdKOSc7SQf7iv+rL4SJIna+KoLYvs2SvUUPmqSByZWancgxgfjzqQxVfeiwzKISVoPPjF/H0BKheFZdkRQjhIvNPZL1JvDi0EpZpUk43DJZCuM/R5JY= X-Forefront-Antispam-Report: CIP:63.163.107.173; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(59896002)(5001960100002)(65806001)(65956001)(50466002)(229853001)(69596002)(36756003)(1096002)(5008740100001)(586003)(11100500001)(1220700001)(83506001)(230700001)(23676002)(77096005)(92566002)(87936001)(76176999)(19580405001)(80316001)(50986999)(19580395003)(65816999)(87266999)(64126003)(54356999)(97736004)(110136002)(4001350100001)(81156007)(47776003)(33656002)(106466001)(189998001)(575784001)(86362001)(2950100001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR02MB301; H:milsmgep12.sandisk.com; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM2PR02MB301; 2:qalL2AHuT86WXf8wdyghIf3+Qf3zA2/vOhJT5WbrbTbWtUL7hUjABTwXZMCXCYGNNUK+05otG06B9xzhK5xrARePeqcsMhjchbg6jxKwEnDLb/E936UabwURVjfuFpVp/447ITL1ZrLBHb1ZrL4jrA==; 3:tSF1UBvuOOypraGoxb3vwIR/amFMf5H/sj3dTPq+PLa/G3u5Vikrsbfth1LDJ6tnZumvRnz1SHDiDrh7jOYoN8lLRORf8mbtpfSMY5rnjkC4GhIkkl3/yLoyC1GCU87sNfcSZOCGYOGOfZzgGC0PVf8KtgMafRNE6Nr2G5NxoLWSVffyK9qCJ66njzqWS+JKuRUrnE1w+6K5Cf0fjLxAyrKKfBH8Ur7hAEeRtf4KczODoO6//DtXJva59WDYkLEKbxriE7Hm8NdSlkyZfaiGoA==; 25:JqggQD/3y4iNpIhqkqFt40nNqnBLYjogn9l8XMVXyxLDr/YNhKcn9orQeGP9m+jdFnQ/tS1ykW2O9U7NVCpoFhxAqOrrasyN6SmtxePyAh52NdmW4rS4CiNOyWHqjLgv6yFOmN4N8Gm64YU+Qy9dVG6hZqYoryv1qtRyjPnYD1vLmXdQ3s9Jx/Aw9s9eAQxlP9k+a00sYxiHcHNTx8e7THx4AYcW179k6MHiWtRi4LCsxjo/QEN1aDyJGHuMmUQql1t/Nro/CUXG/8oynhsf8g== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501001); SRVR:DM2PR02MB301; X-Microsoft-Exchange-Diagnostics: 1; DM2PR02MB301; 20:B4uya/LFXUbv5ItlE38o6l3emcqyzv9X4JtKFWjKr2SHK0IwnnOmaCqIJIOEeRBghdRAOuuEl//gtmxG+Dbs6n0AI+Xzi1wQBObxLM28f+zhg+tVqH2Y4nD+W2E+PPc22kvc1OpZtUKcSj9pakMYUIafV6Uyjz9lEDs5ORMANRxVOdldLlBt2dUEwfQTD/xQwKh7SAdarnLhFu8/07VkPJMS0vf5ICOb+I0EHoKLjGhy1QlIFoHn7FCqVy1ZqXERXXuWnyysegQlvAZt9J+x7zg+xRsgo0MLyxlo1vQ6wjjswIlQ2pAUQ7BLNkfXJj0WHB0YiSsGettPp2A7nYLmTN+MDhZX1nixreGULIZpkj3gfvh1AcQg10m0GDDYi3+JWpY3df8436jQjhtIKXopCoW3yLI7YObTR/E2PdTQtsi9dJr6chXfkW30oAaPUABZaEoBeSTt7X/9N62ecqAk2P73b6gZ5BLNfXBAQVaNFXkvXCRemZ66jzQK16ltLXI0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(34787635062028)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(10201501046)(3002001); SRVR:DM2PR02MB301; BCL:0; PCL:0; RULEID:; SRVR:DM2PR02MB301; X-Microsoft-Exchange-Diagnostics: 1; DM2PR02MB301; 4:1MiApyrucNW4cBmgFoeebdW3S0xK4EM34XIp5BizFPw9C/EJ5pvAlemkmc5nQb5ny/mQqL+Cv1bkVoPofnwK5NXJGYAoXl57nIcTnWK0zRSt4jmYuY7aCsn0Jtz/iaWL+rVXJF3NDxXaEEtSohlpvIORNU7EGvBIxt1npzlStwhhSub3jgPrxMJuvGIKCQf4YnK5tH2edfGmnlNG4PzS32bAllR2PTnGkwMXEkQWtTLosAWyBhO/iful76fUByOURhNqV2khhOVtXneTJCXOvseM1Ar9nJ1aPt7VOnmflAjwyct2CzPMdLXxQvn6aO6Ys9QDOh9n4sQKikU8sw8lB07u7gPEiIv6ejwY0VxVYz/6fw4q+v0YceV8YvOIIf0DVRVSCjjr1osdlnnvqBPiAI9xKR3zPaFVzpovmUMOibPofJHvDxY9JYbCluIV8bR5l6F+L2oCvAy0RUGm2z7Uew== X-Forefront-PRVS: 07778E4001 X-Microsoft-Exchange-Diagnostics: =?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Q5AfkXf1gcuNGeJ6hUUrB8C8E9xJ1oUV/FKu/2y7MtuMJTT54yz3CJu0V1WlRZtA4Z1xTRyt0KRgpBqQSzRVX+tubCU=; 20:DY7mE8/MSh+wPve50NqKL84Vp1NbMg8oBWA0iaX1xm29tvKOHKiUQo/mlfreDihUxpnJi3Xswu9akw1GacTeMzh2gOwkJ6kL2vLuN+Q/UQeUk2zZEoSvS6JegN7++gaobNfBmxw8vsDmOiEMwH6rQnTxreYOEsIw5kGNbamH/yJmmqsZRfE4GPp53cw80xBX/gfl06mlbO3pSr6A5Rj0kuePwCqK5DH+pO6mFg9dWPEpCC1O9qX3xxobDs3j7yva SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2015 18:17:37.1884 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d; Ip=[63.163.107.173]; Helo=[milsmgep12.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR02MB301 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If srp_connect_ch() returns a positive value then that is considered by its caller as a connection failure but this does not result in a scsi_host_put() call and additionally causes the srp_create_target() function to return a positive value while it should return a negative value. Avoid all this confusion and additionally fix a memory leak by ensuring that srp_connect_ch() always returns a value that is <= 0. This patch avoids that a rejected login triggers the following memory leak: unreferenced object 0xffff88021b24a220 (size 8): comm "srp_daemon", pid 56421, jiffies 4295006762 (age 4240.750s) hex dump (first 8 bytes): 68 6f 73 74 35 38 00 a5 host58.. backtrace: [] kmemleak_alloc+0x7a/0xc0 [] __kmalloc_track_caller+0xfe/0x160 [] kvasprintf+0x5b/0x90 [] kvasprintf_const+0x8d/0xb0 [] kobject_set_name_vargs+0x3c/0xa0 [] dev_set_name+0x3c/0x40 [] scsi_host_alloc+0x327/0x4b0 [] srp_create_target+0x4e/0x8a0 [ib_srp] [] dev_attr_store+0x1b/0x20 [] sysfs_kf_write+0x4a/0x60 [] kernfs_fop_write+0x14e/0x180 [] __vfs_write+0x2f/0xf0 [] vfs_write+0xa4/0x100 [] SyS_write+0x54/0xc0 [] entry_SYSCALL_64_fastpath+0x12/0x6f Signed-off-by: Bart Van Assche Reviewed-by: Christoph Hellwig Reviewed-by: Sagi Grimberg Cc: Sebastian Parschauer Cc: stable --- drivers/infiniband/ulp/srp/ib_srp.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 9909022..a074dad 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -994,16 +994,16 @@ static int srp_connect_ch(struct srp_rdma_ch *ch, bool multich) ret = srp_lookup_path(ch); if (ret) - return ret; + goto out; while (1) { init_completion(&ch->done); ret = srp_send_req(ch, multich); if (ret) - return ret; + goto out; ret = wait_for_completion_interruptible(&ch->done); if (ret < 0) - return ret; + goto out; /* * The CM event handling code will set status to @@ -1011,15 +1011,16 @@ static int srp_connect_ch(struct srp_rdma_ch *ch, bool multich) * back, or SRP_DLID_REDIRECT if we get a lid/qp * redirect REJ back. */ - switch (ch->status) { + ret = ch->status; + switch (ret) { case 0: ch->connected = true; - return 0; + goto out; case SRP_PORT_REDIRECT: ret = srp_lookup_path(ch); if (ret) - return ret; + goto out; break; case SRP_DLID_REDIRECT: @@ -1028,13 +1029,16 @@ static int srp_connect_ch(struct srp_rdma_ch *ch, bool multich) case SRP_STALE_CONN: shost_printk(KERN_ERR, target->scsi_host, PFX "giving up on stale connection\n"); - ch->status = -ECONNRESET; - return ch->status; + ret = -ECONNRESET; + goto out; default: - return ch->status; + goto out; } } + +out: + return ret <= 0 ? ret : -ENODEV; } static int srp_inv_rkey(struct srp_rdma_ch *ch, u32 rkey)