Received: by 10.213.65.68 with SMTP id h4csp1859621imn; Mon, 19 Mar 2018 15:29:10 -0700 (PDT) X-Google-Smtp-Source: AG47ELvTtqi9MFITIoexhlk391pkPix2FFiMNK44KNjm4NTOkQddLuxJm6WDOkkyUzcIfUzPCZe3 X-Received: by 2002:a17:902:d03:: with SMTP id 3-v6mr14182130plu.245.1521498550336; Mon, 19 Mar 2018 15:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521498550; cv=none; d=google.com; s=arc-20160816; b=LZ42qQ+K0xe+RIPc/s4vGe2rkBwLdam+LItvkqYTSkCBmMkdP6IchNduaQe1vjtUWb m0JtwlxrPrfalufHlY+dIm3y4ad8qn4yi/S/7tcxs4As9bqghDUFKMeBvNzY+FIWSUXN SGKUrsBOFS7oeoMC4YD/9zibrU5CNzxFRiX0w0C/RoU9zOLPcc+UIXgECXEJ+wjiRMAl 5uVmD53x1lKEu5dkedWJY4icloe99gfTS2f+ufvcDp13JVAaDMqrpZzhCRuTpAGP2lt4 /UCAxDwDrZgbEWaTwpNgjMAWLT7HC5RlVVJbO0y6NP20FMABSt9iYZFJDFX/psV4yi9S db2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=I59lRv+Il4J0NP+Pbxize3dmTZMlp9TentKsbfl1zA4=; b=wdNnAmbterkP4mV8X8nB1bWJPnti5CaAWSUVmuIc+P17qY+jX7VE825MhJ+W3y3k1S rEDLdGZ37rbHZ9DAKot4XxO/ifETNd/tftUUML47c64TLVf2kEa7N1wsBJUd9ysoLlLO ELPACOdjMVrc3LUT2cbvEChWYDO/38Mn5wK5ph1Zd9capJdaEOmpfitJCqtjqjr6isHc bZ+A+S9o7RSNA1N2Ae+Nf7LqYt24/xAiAzmod+iSkRAH2VYN4LDbUmvkQjWyFU1s6TJK qqkWwB/MQCCeJTD8kiv+CtozwUcaY5DEDKuLPNoE1lcnQSXxxPTbqRYxj/jugRgavaWg fheQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=N3Cts9US; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t11si137960pgn.624.2018.03.19.15.28.54; Mon, 19 Mar 2018 15:29:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=N3Cts9US; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032555AbeCSW1Y (ORCPT + 99 others); Mon, 19 Mar 2018 18:27:24 -0400 Received: from mail-sn1nam02on0103.outbound.protection.outlook.com ([104.47.36.103]:38940 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933846AbeCSPsz (ORCPT ); Mon, 19 Mar 2018 11:48:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=I59lRv+Il4J0NP+Pbxize3dmTZMlp9TentKsbfl1zA4=; b=N3Cts9USTM+ujrNwVOQxnSOD5/YlKKWeRxSsdd2RbqEiq7uxsEODAgJ7qqHeDRPe7eaknPuwpnyuUCfH8BbkiIGBXQVVV88cQA47HL5y+4Ep9wLGqxfd7zTpFgL/4JtUtt6MkYc+OwC9bWp90zhS/ERVhdFyeYM+9wOSUTRpE1A= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0936.namprd21.prod.outlook.com (52.132.131.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.609.2; Mon, 19 Mar 2018 15:48:50 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 15:48:50 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: James Smart , James Smart , Christoph Hellwig , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 063/124] nvme_fcloop: fix abort race condition Thread-Topic: [PATCH AUTOSEL for 4.15 063/124] nvme_fcloop: fix abort race condition Thread-Index: AQHTv5mtTZVoP16Aw0myqwhUhTrP8g== Date: Mon, 19 Mar 2018 15:48:07 +0000 Message-ID: <20180319154645.11350-63-alexander.levin@microsoft.com> References: <20180319154645.11350-1-alexander.levin@microsoft.com> In-Reply-To: <20180319154645.11350-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0936;7:4hqDVk9L+9N3dj9ljlZSYJ67SMe5xNeG7JpjQzdGZlHnKjYtO1iVbg892bO89k69CoJ4J5z/k7Z1Mf9SYGmVZOrvtgMcB/OHzPst+xVkg6GBljoABWqq8P8BhAs09+fIWfBcduYcQyxP5zaUxLy0uPMB2yyo5cRKI4qXWeXX9KEiX+MonS3f9IlGOuy1D5kPfvRxn9fJ0gk6yMMDh0ZHN1i+cb6YqhQu67TQaee4tYTwyzJRpmUzrJxjacwE7q/Y;20:FKnMXLB1y41J2PCXtPg931XODHmUDKhuvjxOIr1dV4TfP8fA1P752XyIE2eR9YoKGtEXB557QwibKmoRb3euKOqHbTDcLyvLCwBoUaV6E1swCBhj4XIFphwwj3nKjtO8uAwfNUbzFtQDb3F+93anx9303HhfXNOvXA91itqWJhM= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 45ddc3f4-4612-43cd-e4f8-08d58db0e8d2 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0936; x-ms-traffictypediagnostic: DM5PR2101MB0936: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231221)(944501300)(52105095)(6055026)(61426038)(61427038)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011);SRVR:DM5PR2101MB0936;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0936; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(39860400002)(366004)(376002)(396003)(199004)(189003)(2900100001)(3280700002)(2950100002)(10290500003)(66066001)(106356001)(76176011)(86612001)(6666003)(478600001)(5250100002)(6512007)(6486002)(107886003)(36756003)(97736004)(72206003)(25786009)(6436002)(53936002)(7736002)(2501003)(54906003)(110136005)(105586002)(10090500001)(2906002)(86362001)(305945005)(5660300001)(316002)(8676002)(6346003)(1076002)(3846002)(3660700001)(81156014)(4326008)(14454004)(26005)(6116002)(102836004)(8936002)(81166006)(6506007)(186003)(22452003)(39060400002)(59450400001)(99286004)(68736007)(575784001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0936;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: FPj86/ushOHFuOxfXIwJfoy8L6PxogFqKIz+6plnQi0O0CiDN/uT4DJ5dbPRW8ju8KZD5q++Bk2AovY06O3WiZUqK0DjOctNM5OQpL3sJ9oaWcfotOyv90Oms9YY2sVI628oE9BbOPqkJlWoywEpDv7kGbZn1Afn4SPYi8pCj8SrqY3n1UsZaqRN5BlzVviEeUCEL4uheGQqiXyFzQR2G66TGzdFZcAxL7DZHMEbCTaalsvMfy+oj+EueO129An43w1KcW0HOQXNF7GBrJ0RiRidMtCBHQz5KPI/MT8WLX6blE7TuD+5F+V8jFcnJKThQuV2aIpVQG3/51dIds/D0g== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45ddc3f4-4612-43cd-e4f8-08d58db0e8d2 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 15:48:07.9573 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0936 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Smart [ Upstream commit 278e096063f1914fccfc77a617be9fc8dbb31b0e ] A test case revealed a race condition of an i/o completing on a thread parallel to the delete_association generating the aborts for the outstanding ios on the controller. The i/o completion was freeing the target fcloop context, thus the abort task referenced the just-freed memory. Correct by clearing the target/initiator cross pointers in the io completion and abort tasks before calling the callbacks. On aborts that detect already finished io's, ensure the complete context is called. Signed-off-by: James Smart Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/target/fcloop.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c index bedb66521a4a..cd1adb9e7e9d 100644 --- a/drivers/nvme/target/fcloop.c +++ b/drivers/nvme/target/fcloop.c @@ -374,6 +374,7 @@ fcloop_tgt_fcprqst_done_work(struct work_struct *work) =20 spin_lock(&tfcp_req->reqlock); fcpreq =3D tfcp_req->fcpreq; + tfcp_req->fcpreq =3D NULL; spin_unlock(&tfcp_req->reqlock); =20 if (tport->remoteport && fcpreq) { @@ -615,11 +616,7 @@ fcloop_fcp_abort(struct nvme_fc_local_port *localport, =20 if (!tfcp_req) /* abort has already been called */ - return; - - if (rport->targetport) - nvmet_fc_rcv_fcp_abort(rport->targetport, - &tfcp_req->tgt_fcp_req); + goto finish; =20 /* break initiator/target relationship for io */ spin_lock(&tfcp_req->reqlock); @@ -627,6 +624,11 @@ fcloop_fcp_abort(struct nvme_fc_local_port *localport, tfcp_req->fcpreq =3D NULL; spin_unlock(&tfcp_req->reqlock); =20 + if (rport->targetport) + nvmet_fc_rcv_fcp_abort(rport->targetport, + &tfcp_req->tgt_fcp_req); + +finish: /* post the aborted io completion */ fcpreq->status =3D -ECANCELED; schedule_work(&inireq->iniwork); --=20 2.14.1