Received: by 10.192.165.156 with SMTP id m28csp67072imm; Tue, 10 Apr 2018 16:33:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx49fNuD4vNobkBDDQKCMZzAxcwj95VB7dMZA5VEeLdvogHf2J5r2mgJjrbK0q2SSRb49Aoc/ X-Received: by 2002:a17:902:7102:: with SMTP id a2-v6mr2446150pll.87.1523403223013; Tue, 10 Apr 2018 16:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523403222; cv=none; d=google.com; s=arc-20160816; b=skc5sSW6m9xjjs8g/Cbdri9U3CwQOZN0KkUVGNabotxYyhxuvRLVbT+rj8IU35AQfy Y2YM14NXfVtUHc33ZCGQ+TGCeymCNJ9/3xFcKM3YWVQjDyXyf0XbZae5RZoaC1LvIFSn 9IZ+5Fc5LTAUBYSroSi5k8hFeKxhmRJM+cORouSHVMEfsPMnJnBInNBco/hmyVvBw6jS CmUDvXZ5Q7iDHlYsD+VnGnc8EUIUP8fiC5IKZdya6XSmgbSR1f4J/dvDlSPV2ovM0uGJ SoF31M4SHzeFfU5dDI1oUfa8bgVUd+bqcqVGHxNQNPMsrO22lARoD/1UOH/7kxcRUKQC U8XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=0bdZ2W7o21NOUT65l7Ul++mGqi2sRI7VbdXuzcI9qsY=; b=YlL23f3hdW72fuJXAFItfohkh1136G1Wjr8HXyyTOXANBnAAcjXIroh7V/ayDSw6XU kMujLCTe1qrH9uKyNrASRCD2gaOCh/n3LjeUEU3km3AChNDqgb5nseDGXozlDqHyUSYr tonL0hBpxjTpZlEfXL5X6X7Ved/mECuXUD5DVSc+LX7z0Tt6WK42cy7c5I3v8Alw5E7R RTM7nzcd3VaOQKppH1JCHkYoAavclg/U10a/Nk3ArjJR/fYuYdUQeRMtTBU0d5ZyYdi/ fnICF6aoHfjcHeQQMl5I06ySHYNKBEB49E0+Zb2TuSmkPt2D/dE1cDtK3kDAc7JmgF44 htJQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6-v6si3713427plt.580.2018.04.10.16.33.06; Tue, 10 Apr 2018 16:33:42 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755394AbeDJX2X (ORCPT + 99 others); Tue, 10 Apr 2018 19:28:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39424 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754253AbeDJW3P (ORCPT ); Tue, 10 Apr 2018 18:29:15 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 73B0FD4F; Tue, 10 Apr 2018 22:29:14 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Smart , Christoph Hellwig , Sasha Levin Subject: [PATCH 4.15 059/168] nvme_fcloop: fix abort race condition Date: Wed, 11 Apr 2018 00:23:21 +0200 Message-Id: <20180410212802.716886067@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/target/fcloop.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/drivers/nvme/target/fcloop.c +++ b/drivers/nvme/target/fcloop.c @@ -374,6 +374,7 @@ fcloop_tgt_fcprqst_done_work(struct work spin_lock(&tfcp_req->reqlock); fcpreq = tfcp_req->fcpreq; + tfcp_req->fcpreq = NULL; spin_unlock(&tfcp_req->reqlock); if (tport->remoteport && fcpreq) { @@ -615,11 +616,7 @@ fcloop_fcp_abort(struct nvme_fc_local_po 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; /* break initiator/target relationship for io */ spin_lock(&tfcp_req->reqlock); @@ -627,6 +624,11 @@ fcloop_fcp_abort(struct nvme_fc_local_po tfcp_req->fcpreq = NULL; spin_unlock(&tfcp_req->reqlock); + if (rport->targetport) + nvmet_fc_rcv_fcp_abort(rport->targetport, + &tfcp_req->tgt_fcp_req); + +finish: /* post the aborted io completion */ fcpreq->status = -ECANCELED; schedule_work(&inireq->iniwork);