Received: by 10.192.165.156 with SMTP id m28csp235542imm; Tue, 10 Apr 2018 20:36:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+GaLE2Z0A0tJE5FeSTIGWDq9pRsiuRQ6844IZjWiwNV1DNwMTmUms+baY9IQgjsaWUaNKL X-Received: by 2002:a17:902:464:: with SMTP id 91-v6mr3171726ple.126.1523417765096; Tue, 10 Apr 2018 20:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523417765; cv=none; d=google.com; s=arc-20160816; b=WU8o6q5yTGpqCVmHPO9LWPibaE6AeAArx9r8FLodlRbUt5EfhmMTWCbSjrMfXkq1Pw S3zhoDVRRtt2Que0JJmh7rpRjMPSwR3ygL8/g3uzlcHpOPrMD9Q0hdE6t7gi+bNU1fwS lr1V8C8B8UbZEtS9KrPH/GHBauCQrMYMgpx2/MmQgl27IrS5FNMXPCgof7XzWfPuXTVb anskwdHilgZJtGd487jODmMSXuaSxFDX71IXidnD/Tu1vJTTOmmmC3F2nne4IA53LmNr k0FkZUqr6Jga9leIo3H39DmAXnD8Temi4JR59fGzt9HBSlJ3xQTibU9TIDnq5jMcp7CT 6vXg== 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=JKOzUenDmjKYFrFtU7K3//sEP4BJBbhMUFegO6X+BiQ=; b=UgN3KoEy0SRxqsR9M9L9aL4rSthQF2L3PV4MMyjKCidasCOeN8Sle2fRBej1OK7yd0 1qutu8GbWIL1P7w4l20LcUe5Qs2ba/0U1K9CNq4elcs8mfnqXOLSgEP+dS99wTbtrRWD qMj00MjmCXwSJtmiY1yQ2ZdfZbT2RUFW4DfizOCpReb+hWZg+Z+LLG+lKcu3yhpGrW/z wGSIY/k20kUAlJQHl5U1qXgVBWAmlLCA1Xs0PkcFxnVdl2aTfir/KLhNyOw6yX9hJyfU bs5KEkCydHu/7II8gSg9lQ5MBCH3tHVsCUkguqbVyEW/V1EvGZ2axU3Z1N3SBn86IY0k pJyA== 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 c6si177550pfl.136.2018.04.10.20.35.28; Tue, 10 Apr 2018 20:36:05 -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 S932263AbeDJWfe (ORCPT + 99 others); Tue, 10 Apr 2018 18:35:34 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42174 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932244AbeDJWfb (ORCPT ); Tue, 10 Apr 2018 18:35:31 -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 17685DDF; Tue, 10 Apr 2018 22:35:30 +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.14 044/138] nvme_fcloop: fix abort race condition Date: Wed, 11 Apr 2018 00:23:54 +0200 Message-Id: <20180410212907.231417880@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@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.14-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);