From patchwork Tue Aug 11 15:58:57 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: 6993321 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 EC1519F344 for ; Tue, 11 Aug 2015 15:59:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 03CD220525 for ; Tue, 11 Aug 2015 15:59:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF0FA2013D for ; Tue, 11 Aug 2015 15:59:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965131AbbHKP7P (ORCPT ); Tue, 11 Aug 2015 11:59:15 -0400 Received: from mail-by2on0087.outbound.protection.outlook.com ([207.46.100.87]:41882 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965476AbbHKP7K (ORCPT ); Tue, 11 Aug 2015 11:59:10 -0400 Received: from BLUPR0201CA0030.namprd02.prod.outlook.com (10.163.116.40) by CY1PR0201MB0747.namprd02.prod.outlook.com (10.160.141.15) with Microsoft SMTP Server (TLS) id 15.1.225.19; Tue, 11 Aug 2015 15:59:07 +0000 Received: from BL2FFO11FD014.protection.gbl (2a01:111:f400:7c09::142) by BLUPR0201CA0030.outlook.office365.com (2a01:111:e400:52e7::40) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Tue, 11 Aug 2015 15:59:00 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.172) smtp.mailfrom=sandisk.com; mellanox.com; dkim=none (message not signed) header.d=none; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.172 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.172; helo=milsmgep11.sandisk.com; Received: from milsmgep11.sandisk.com (63.163.107.172) by BL2FFO11FD014.mail.protection.outlook.com (10.173.160.222) with Microsoft SMTP Server id 15.1.243.9 via Frontend Transport; Tue, 11 Aug 2015 15:58:58 +0000 Received: from MILHUBIP03.sdcorp.global.sandisk.com ( [172.22.12.162]) by milsmgep11.sandisk.com (Symantec Messaging Gateway) with SMTP id D0.1E.04667.2CB1AC55; Tue, 11 Aug 2015 08:58:58 -0700 (PDT) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.224.2; Tue, 11 Aug 2015 08:58:10 -0700 X-AuditID: ac160a68-f790b6d00000123b-35-55ca1bc2a1b0 Received: from [10.60.52.33] ( [10.177.8.100]) by milsmgip12.sandisk.com (Symantec Messaging Gateway) with SMTP id CE.C3.04661.1CB1AC55; Tue, 11 Aug 2015 08:58:57 -0700 (PDT) Subject: Re: [PATCH] IB/srp: Fix possible use-after-free To: Sagi Grimberg , Sagi Grimberg , "linux-rdma@vger.kernel.org" References: <1439216574-25936-1-git-send-email-sagig@mellanox.com> <55C8BB38.1060808@sandisk.com> <55CA09E5.2070208@dev.mellanox.co.il> From: Bart Van Assche Message-ID: <55CA1BC1.3060609@sandisk.com> Date: Tue, 11 Aug 2015 08:58:57 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55CA09E5.2070208@dev.mellanox.co.il> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRmVeSWpSXmKPExsWyRoxnke4h6VOhBj0H2CyeHeplsXh9/CmT xY22B2wOzB7TZ2xi9Xg2/TCTx+dNcgHMUVw2Kak5mWWpRfp2CVwZa+8vYCxYLFmxrO0iYwPj C6EuRk4OCQETieNrH7JD2GIS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93LEmzNvfZ/GSxuKr2c0MY44YdRtuX1XyaKSvv+2nHrUDF VWtynebrRh3RqBOb9X6WbGHnk5m3EyN52Iut3Ix1fS2P50ucUw6/fqB2VpuZTLskn/n3lENP 9Dxid8y5tyFgqhJLcUaioRZzUXEiAD5HsiTtAQAA X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD014; 1:HkwxgzKjFk81MGvEndGpsqGmJhSA7fq1pRaHoWz02b2F8hInAIekqQQaWlyj5urRPsaq4ynbqIIb5aayoHRcdwmaZvKyYOEbvTVtD+2nb60kHLz5qWYxaN0RF3bP6+98t+M8KL3a5tJTeyN+Dv1t1cYhV7rRmN4Td5Zda+Vzkp947uSTrd8GXd9yN9QSTiN20GeZ66YQ4cgcqn7qv+lZaRa65TXgbcONUaXXXmRnKhy5TxQEQiNgpcHHtSkyDdCHSPXnmXvXiAjOkbowTjVzhPMYy3A3pr+V/D6Pzy5/oNbpTq/lCu/Tu5Ca9+8OlghL6eRmGTu+MOCw/R9pvLdCPTBNH7vOyw+pJzF/r+WnzYGUd+R9OSeKp3fPKnAimvES X-Forefront-Antispam-Report: CIP:63.163.107.172; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(3050300001)(164054003)(479174004)(377454003)(24454002)(199003)(189002)(62966003)(5001860100001)(4001540100001)(87936001)(69596002)(46102003)(81156007)(92566002)(33656002)(77156002)(4001350100001)(83506001)(50466002)(86362001)(230783001)(106466001)(80316001)(23676002)(2501003)(50986999)(5001770100001)(36756003)(59896002)(77096005)(68736005)(5001960100002)(47776003)(64126003)(65816999)(107886002)(189998001)(87266999)(97736004)(65806001)(65956001)(2950100001)(5001830100001)(54356999)(64706001)(5001920100001)(76176999); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0201MB0747; H:milsmgep11.sandisk.com; FPR:; SPF:Pass; PTR:ErrorRetry; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB0747; 2:ekl2ohQqqtWahwEjgxtKwIFrJSjimfQ+4dkQkPCJvOUcQjpybeW9p5HNr8bN9ijdGFijxdoiZMQbmT6f2bTU1018k/68yLjcREsz9w0+tJuJS9RfGGTIBJ+03mkV04943dkLVkAOvjfntpc2Z+TDleWR6HJFNnRIRtgVvpRRgw0=; 3:Pqwt3wApFExs+LnVLMdHxbIRvxvtbdjewEO14WIZhAF4z4v9aR3Rp8QL8DQzfzwxmJV96wXcpqZt7jcUukxtfS/kJRflGYOCJ2kPRiBVRu+ADvxOEjHV5Fm2K2UKvlYMce6H9MGJhd7eBMctCPW/Xxv5KJHUMcLS1sF400WDONyidzQiHp79IWOwp9hb+GC3khR3luYnCBCpSppaGc75raW26dnYSZv++EnLkvRaKvXO5n5v16K2t6BOwByTU56F; 25:0C6Hqdha2k8P9vvXl7EKq1vtujEIdYvGXZJAFR+uoa140/19si72wH7uzWrNu/Vi2BXd35hqXG6TV2McahFtvieAhHLyEL6RHvtvR8/zHTm6HeAtWq1pHxvolZnYWOHGdKKayNYSPiIG2StJ1CfiKvGKhPdtKlK76lqK/JhhW8/ODcVf5wzDCje7zwNSTFes+tT99NRmmslr4x2kt/16qbKI2vx4H/9b0nS3REEvJygEP1xUb09HGbScPlN26RKfX6Z7nX7M2/CrL2fwjhfWKg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0201MB0747; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB0747; 20:eurorjK2pC5XWghsJgJj9pHsBQpUZYnYXOzjg+ZaXnHglCHAMZCUgp/Yn3XUNvTc2R2yWRcBGGFb28o28pRwEHl46AFu/+1x340UTDK/jmjAY5n/ct9HnubBnKrf3nDa5ecTelK4jKf7vpGD031F2X51axuZYnUhynnVfHZeLUIZNHyEw8Lu8cYJY6wUvfSwxrCFz1SUI/AunpoY/Fq+83N9h7pcHjU6VAjsNNOY6vQfv0fHLV8kuWO73bpdtz9HyGsAKxVNkT56TzLz+80WdbVB6WZ4vr9NyDYM9ND4tHpxZQUVwHWLRIAGpgGU3/uFD5pCc58UKNV6i4+UpYtJ7K9kNVU0vj50hovW8bj+yRkV7vTUZTB0puJfvFCdmASWQwewAqGJSad619RRzRnrlJkP1aQmhgQhAzgqEan1eDQZP5yQkwd/yRiItUtjnvnX0DbvrJJMOLaNjyeSI96Q7yNhVPJyQgls8DjFWhnk4f2VHX0S3jfNao5+iw350C0h; 4:ZzQxJgOVaRvwvmGTy/Rp8W/oP+hnv0ZVNqEyoYt7/I6exFWwkDTALWVX2rNpxrBBc0u6I1hhMNs8afBqTj7nBDBsYDETWWKvtaqfpjVH403WaUQeMh3Bps+UswxoYs434ivZcyfq4WpXeWxydKZ+5F/8JHT5TBqUjtcs9U87LbxBSDHHIV21NB83LNq0eQYAM+Gj2kb0Pn+aSvsqLO7eCrQwd3vD3vkRf5hs/5xS262CKF9lVfN2/6uNPo4eg5FXCPswnEsRHK109it2e5VJOB+DJwRsUt/ReASMjNmnopw= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:CY1PR0201MB0747; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0201MB0747; X-Forefront-PRVS: 066517B35B X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTFQUjAyMDFNQjA3NDc7MjM6clpmanRPci9jSXdHeWd5WWVtcnVrdFh3?= =?utf-8?B?eDJVV2Z2b3BvY1h0UE5LRkNKQldRVHRCSldvL0hKemFuS2Eyam5OUmp0c2tm?= =?utf-8?B?YzN0S3NZbnR6dDZmZkRFSnB0QXUwTUFFdGRQSkdaMzhkWUZ1ZlFKWDUyNEsv?= =?utf-8?B?NS8xUE1uaFhwYnkzaWk0MEpVSjRYQ0lGVnVOSzJycW1CQWx3b1R3NDNRTTR4?= =?utf-8?B?RUs2VE5leWQ5cTlDdXhkaWdM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YPkICiOuaG4RD4=; 20:JXVilB9wuxStWnCxG96Y1zBNmpl3gWlS5AOoQ0SkVNzas4x5et9yLaplbBSpvq+xR9ni6sMeUM0i1TNa+nE4DPWUGeWqf9VuXmpzMGeoV7H9SzMNsGbI6Hq3Eja7f61PF0W4N25HW6rlNomW8OKJL79ARYW78/cnXB/WyGA5TiE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2015 15:58:58.5904 (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.172]; Helo=[milsmgep11.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0201MB0747 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 On 08/11/2015 07:42 AM, Sagi Grimberg wrote: > diff --git a/drivers/infiniband/ulp/srp/ib_srp.c > b/drivers/infiniband/ulp/srp/ib_srp.c > index 3a1514c..b220856 100644 > --- a/drivers/infiniband/ulp/srp/ib_srp.c > +++ b/drivers/infiniband/ulp/srp/ib_srp.c > @@ -546,6 +546,17 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) > if (ret) > goto err_qp; > > + if (ch->qp) > + srp_destroy_qp(ch); > + if (ch->recv_cq) > + ib_destroy_cq(ch->recv_cq); > + if (ch->send_cq) > + ib_destroy_cq(ch->send_cq); > + > + ch->qp = qp; > + ch->recv_cq = recv_cq; > + ch->send_cq = send_cq; > + > if (dev->use_fast_reg && dev->has_fr) { > fr_pool = srp_alloc_fr_pool(target); > if (IS_ERR(fr_pool)) { > @@ -570,17 +581,6 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) > ch->fmr_pool = fmr_pool; > } > > - if (ch->qp) > - srp_destroy_qp(ch); > - if (ch->recv_cq) > - ib_destroy_cq(ch->recv_cq); > - > - ch->qp = qp; > - ch->recv_cq = recv_cq; > - ch->send_cq = send_cq; > - > kfree(init_attr); > return 0; > > Sorry for the mixup. Does this patch make more sense? On second thought ... with your patch, if the "goto err_qp" branch in srp_create_ch_ib() is taken upon return ch->qp, ch->recv_cq and ch->send_cq will be dangling pointers. That will have bad consequences in the subsequent srp_free_ch_ib() call. How about replacing the above patch with the (untested) patch below ? Thanks, Bart. [PATCH] IB/srp: Avoid that a completion during reconnect causes a crash Untested. --- drivers/infiniband/ulp/srp/ib_srp.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 2968b7b..1f9ed68 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -554,9 +554,6 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) "FR pool allocation failed (%d)\n", ret); goto err_qp; } - if (ch->fr_pool) - srp_destroy_fr_pool(ch->fr_pool); - ch->fr_pool = fr_pool; } else if (!dev->use_fast_reg && dev->has_fmr) { fmr_pool = srp_alloc_fmr_pool(target); if (IS_ERR(fmr_pool)) { @@ -565,9 +562,6 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) "FMR pool allocation failed (%d)\n", ret); goto err_qp; } - if (ch->fmr_pool) - ib_destroy_fmr_pool(ch->fmr_pool); - ch->fmr_pool = fmr_pool; } if (ch->qp) @@ -577,6 +571,16 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) if (ch->send_cq) ib_destroy_cq(ch->send_cq); + if (dev->use_fast_reg && dev->has_fr) { + if (ch->fr_pool) + srp_destroy_fr_pool(ch->fr_pool); + ch->fr_pool = fr_pool; + } else if (!dev->use_fast_reg && dev->has_fmr) { + if (ch->fmr_pool) + ib_destroy_fmr_pool(ch->fmr_pool); + ch->fmr_pool = fmr_pool; + } + ch->qp = qp; ch->recv_cq = recv_cq; ch->send_cq = send_cq;