Received: by 10.213.65.68 with SMTP id h4csp473736imn; Fri, 16 Mar 2018 08:50:54 -0700 (PDT) X-Google-Smtp-Source: AG47ELvISdg8k3tODmDfndyFAb3cKJjO4FXVtoJ3WyX0cQrfamt/pimBCPE0+0ueNBV75qq6Tify X-Received: by 10.98.99.196 with SMTP id x187mr1996265pfb.182.1521215454516; Fri, 16 Mar 2018 08:50:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521215454; cv=none; d=google.com; s=arc-20160816; b=IM0URROGc0E2Rls9f4mMAM0NTD0atB7Ziw/vcCGgNuRyTRnXBVLmVTn1R8fDjsapLo DTxL3Lrn40Mvc9+tx91p5R2Z9IYICk3G5T3L6A4jHKt3y71LnzqCVX01aQkKVx41p5ao dBjXQIZTrQz75UDHiM43CgqSZklig6E+eW25OKHVIsDyocGtfncu0EWqOOGfpfhP2v9E Bepk1Sr/DFZJhNKMz8klanVfN4jPxEI18kAkC9d7EsWNkUYb5BpSjsczPATBg2OEOHZn nUDMEyN0ZpF5m5tKYGpLIkSeriXTCbGBxFVbdX3g2BqBcvlFt7BQeqDNXdSgLq+Tqcen f1BA== 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=cTqJJ74otfNfjgnJrsaSKw32X6v+rANMKNsBkvrPmxI=; b=rG4XxWqY0rbV8T+ik7wilh0gP/xPMn/NaFh17VEbJyEiPzibe6HEPORyDmXxbeztDW LT7jwHc+J/psmOhQdnwpwcpQOU2pJaItW666W7c2w59OALBgi3iKGiaR7eigLiMuaOFx mQSoaIhP2qQ10NVj1uk4GCdGatuqDLxX7XsE3g28RBnJJhw75M0g80KrgNGx34D2fKuS BNxmkNlHKMzOrII7rcwzn5U84GoVi0A4jJLnjSD79GxOMk5gx+OO5xHyqY9ioUIQtzhf E7mqeaPJu9jbmGwjRXv6eN/nRVWonZkCDrg/CMExtR6IrckZQm+H6WI2b7ylXEKdOsrf UGuQ== 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 j6si5682676pfa.413.2018.03.16.08.50.39; Fri, 16 Mar 2018 08:50:54 -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 S1754923AbeCPPod (ORCPT + 99 others); Fri, 16 Mar 2018 11:44:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45962 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934548AbeCPPo2 (ORCPT ); Fri, 16 Mar 2018 11:44:28 -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 EACE9E13; Fri, 16 Mar 2018 15:44:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dick Kennedy , James Smart , Hannes Reinecke , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.15 081/128] scsi: lpfc: Fix crash during driver unload with running nvme traffic Date: Fri, 16 Mar 2018 16:23:42 +0100 Message-Id: <20180316152340.674900786@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@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 3386f4bdd243ad5a9094d390297602543abe9902 ] When the driver is unloading, the nvme transport could be in the process of submitting new requests, will send abort requests to terminate associations, or may make LS-related requests. The driver's abort and request entry points currently is ignorant of the unloading state and is starting the requests even though the infrastructure to complete them continues to teardown. Change the entry points for new requests to check whether unloading and if so, reject the requests. Abort routines check unloading, and if so, noop the request. An abort is noop'd as the teardown paths are already aborting/terminating the io outstanding at the time the teardown initiated. Signed-off-by: Dick Kennedy Signed-off-by: James Smart Reviewed-by: Hannes Reinecke Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/lpfc/lpfc_nvme.c | 14 ++++++++++++++ drivers/scsi/lpfc/lpfc_nvmet.c | 11 +++++++++++ 2 files changed, 25 insertions(+) --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -419,6 +419,9 @@ lpfc_nvme_ls_req(struct nvme_fc_local_po if (vport->load_flag & FC_UNLOADING) return -ENODEV; + if (vport->load_flag & FC_UNLOADING) + return -ENODEV; + ndlp = lpfc_findnode_did(vport, pnvme_rport->port_id); if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE | LOG_NVME_IOERR, @@ -534,6 +537,9 @@ lpfc_nvme_ls_abort(struct nvme_fc_local_ vport = lport->vport; phba = vport->phba; + if (vport->load_flag & FC_UNLOADING) + return; + ndlp = lpfc_findnode_did(vport, pnvme_rport->port_id); if (!ndlp) { lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_ABTS, @@ -1260,6 +1266,11 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_l goto out_fail; } + if (vport->load_flag & FC_UNLOADING) { + ret = -ENODEV; + goto out_fail; + } + /* Validate pointers. */ if (!pnvme_lport || !pnvme_rport || !freqpriv) { lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR | LOG_NODE, @@ -1487,6 +1498,9 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local vport = lport->vport; phba = vport->phba; + if (vport->load_flag & FC_UNLOADING) + return; + /* Announce entry to new IO submit field. */ lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_ABTS, "6002 Abort Request to rport DID x%06x " --- a/drivers/scsi/lpfc/lpfc_nvmet.c +++ b/drivers/scsi/lpfc/lpfc_nvmet.c @@ -635,6 +635,9 @@ lpfc_nvmet_xmt_ls_rsp(struct nvmet_fc_ta if (phba->pport->load_flag & FC_UNLOADING) return -ENODEV; + if (phba->pport->load_flag & FC_UNLOADING) + return -ENODEV; + lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, "6023 NVMET LS rsp oxid x%x\n", ctxp->oxid); @@ -721,6 +724,11 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_ta goto aerr; } + if (phba->pport->load_flag & FC_UNLOADING) { + rc = -ENODEV; + goto aerr; + } + #ifdef CONFIG_SCSI_LPFC_DEBUG_FS if (ctxp->ts_cmd_nvme) { if (rsp->op == NVMET_FCOP_RSP) @@ -822,6 +830,9 @@ lpfc_nvmet_xmt_fcp_abort(struct nvmet_fc if (phba->pport->load_flag & FC_UNLOADING) return; + + if (phba->pport->load_flag & FC_UNLOADING) + return; lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS, "6103 NVMET Abort op: oxri x%x flg x%x ste %d\n",