Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp685050pxv; Thu, 22 Jul 2021 09:41:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBrb8qjRP8TXKd4YhQuue/LP1jper2MhAs2QVRQ6f0lPn5F4FnEsmGxiVoOrrUG5x3wFUs X-Received: by 2002:a05:6638:4115:: with SMTP id ay21mr382304jab.13.1626972102322; Thu, 22 Jul 2021 09:41:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626972102; cv=none; d=google.com; s=arc-20160816; b=HV1ksgwRBPOWJBL/jaMAkqUErZ4FtUsZ1n3BRNnYgI1Gdi5eLxz1u0dqJJjCcHuJpf SeVKxfLJniHo04R63I444v6Qz08prNw/fgANFMQbH5X6zvDr9biVb6phZH6RX9edAFIT qfQWLqu7S+jNRpbP0Pj3T1Z6nUvnLj7c3GUfaNT3/HoaXBefv/r5WJC22oCrjoMu1w3p qCQoJPPThQncUp4ywtrUneadbHPvdB2R3WlqrnzYXnViQgYZB5WLemt1OAshv26M5vTs uoXFX4tTjAOyfC9pd35qqw0sRRm6Qzx4Zy2iEEMChq93y/hxDS9klDQeHUnGq6OXXMx4 0R7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yN8NhB/am2gOB/+3yWSCW4c92HduiOb+dlZ5Bs1Wcms=; b=JRCtxUT7lvZpX35eaWf0aw55rJqjxnG4G7xnErQEhvbyEMMNB5O9h1wZ6iqsFrWmPw LPe+86SqhLq/B2LieOWhf7ZCqfmPuPRbzGUQdG72pD+gGug67k35GNnYsCWNKhgK2Ndx Lkx0DNvwjvEt5fxk/FDi3NbaJaErrsgcu6VS+vrSjm4rwohhikouO6nWKlndOUOXP/ul HUx4FxaKc2gswAOFr8OVxtp/d6EkNfczZOdVQZKXqigMl0W9QAYUfuYpfZN91j9jxSih kG5ssuDgSawXsQM9EoMfP8PADS3ajKlYnFA39BZZnCXptQWWN9RgjAWEe7dGDKqekQZn Vc3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TQez4S2P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g13si10147008iow.65.2021.07.22.09.41.30; Thu, 22 Jul 2021 09:41:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TQez4S2P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233385AbhGVQAI (ORCPT + 99 others); Thu, 22 Jul 2021 12:00:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:34322 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232565AbhGVP6C (ORCPT ); Thu, 22 Jul 2021 11:58:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 94BC86136D; Thu, 22 Jul 2021 16:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626971917; bh=oKjWj7Onv+W+k1uW4T3TWlfaX1bu26QRsVcZxGXlQgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TQez4S2PBzU9DzeggqKwqItJumDgksF8DHYCFf5bz9OiHOQN//TLvLKvdohvnhvYK hjffCqv5dJ9waGTecYAN4CALizbNdAk4/eKKotCt59hBjSOHrR3Y5Y/IhnXi+RSlOP LRhlldH0DSnzIF3laudzsm0kpFp0gQJuGyKuvWG0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Javed Hasan , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.10 074/125] scsi: qedf: Add check to synchronize abort and flush Date: Thu, 22 Jul 2021 18:31:05 +0200 Message-Id: <20210722155627.141959144@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210722155624.672583740@linuxfoundation.org> References: <20210722155624.672583740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Javed Hasan [ Upstream commit df99446d5c2a63dc6e6920c8090da0e9da6539d5 ] A race condition was observed between qedf_cleanup_fcport() and qedf_process_error_detect()->qedf_initiate_abts(): [2069091.203145] BUG: unable to handle kernel NULL pointer dereference at 0000000000000030 [2069091.213100] IP: [] qedf_process_error_detect+0x96/0x130 [qedf] [2069091.223391] PGD 1943049067 PUD 194304e067 PMD 0 [2069091.233420] Oops: 0000 [#1] SMP [2069091.361820] CPU: 1 PID: 14751 Comm: kworker/1:46 Kdump: loaded Tainted: P OE ------------ 3.10.0-1160.25.1.el7.x86_64 #1 [2069091.388474] Hardware name: HPE Synergy 480 Gen10/Synergy 480 Gen10 Compute Module, BIOS I42 04/08/2020 [2069091.402148] Workqueue: qedf_io_wq qedf_fp_io_handler [qedf] [2069091.415780] task: ffff9bb9f5190000 ti: ffff9bacaef9c000 task.ti: ffff9bacaef9c000 [2069091.429590] RIP: 0010:[] [] qedf_process_error_detect+0x96/0x130 [qedf] [2069091.443666] RSP: 0018:ffff9bacaef9fdb8 EFLAGS: 00010246 [2069091.457692] RAX: 0000000000000000 RBX: ffff9bbbbbfb18a0 RCX: ffffffffc0672310 [2069091.471997] RDX: 00000000000005de RSI: ffffffffc066e7f0 RDI: ffff9beb3f4538d8 [2069091.486130] RBP: ffff9bacaef9fdd8 R08: 0000000000006000 R09: 0000000000006000 [2069091.500321] R10: 0000000000001551 R11: ffffb582996ffff8 R12: ffffb5829b39cc18 [2069091.514779] R13: ffff9badab380c28 R14: ffffd5827f643900 R15: 0000000000000040 [2069091.529472] FS: 0000000000000000(0000) GS:ffff9beb3f440000(0000) knlGS:0000000000000000 [2069091.543926] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [2069091.558942] CR2: 0000000000000030 CR3: 000000193b9a2000 CR4: 00000000007607e0 [2069091.573424] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [2069091.587876] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [2069091.602007] PKRU: 00000000 [2069091.616010] Call Trace: [2069091.629902] [] qedf_process_cqe+0x109/0x2e0 [qedf] [2069091.643941] [] qedf_fp_io_handler+0x26/0x60 [qedf] [2069091.657948] [] process_one_work+0x17f/0x440 [2069091.672111] [] worker_thread+0x126/0x3c0 [2069091.686057] [] ? manage_workers.isra.26+0x2a0/0x2a0 [2069091.700033] [] kthread+0xd1/0xe0 [2069091.713891] [] ? insert_kthread_work+0x40/0x40 Add check in qedf_process_error_detect(). When flush is active, let the cmds be completed from the cleanup contex. Link: https://lore.kernel.org/r/20210624171802.598-1-jhasan@marvell.com Signed-off-by: Javed Hasan Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/qedf/qedf_io.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c index 4869ef813dc4..63f99f4eeed9 100644 --- a/drivers/scsi/qedf/qedf_io.c +++ b/drivers/scsi/qedf/qedf_io.c @@ -1520,9 +1520,19 @@ void qedf_process_error_detect(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, { int rval; + if (io_req == NULL) { + QEDF_INFO(NULL, QEDF_LOG_IO, "io_req is NULL.\n"); + return; + } + + if (io_req->fcport == NULL) { + QEDF_INFO(NULL, QEDF_LOG_IO, "fcport is NULL.\n"); + return; + } + if (!cqe) { QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO, - "cqe is NULL for io_req %p\n", io_req); + "cqe is NULL for io_req %p\n", io_req); return; } @@ -1538,6 +1548,16 @@ void qedf_process_error_detect(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, le32_to_cpu(cqe->cqe_info.err_info.rx_buf_off), le32_to_cpu(cqe->cqe_info.err_info.rx_id)); + /* When flush is active, let the cmds be flushed out from the cleanup context */ + if (test_bit(QEDF_RPORT_IN_TARGET_RESET, &io_req->fcport->flags) || + (test_bit(QEDF_RPORT_IN_LUN_RESET, &io_req->fcport->flags) && + io_req->sc_cmd->device->lun == (u64)io_req->fcport->lun_reset_lun)) { + QEDF_ERR(&qedf->dbg_ctx, + "Dropping EQE for xid=0x%x as fcport is flushing", + io_req->xid); + return; + } + if (qedf->stop_io_on_error) { qedf_stop_all_io(qedf); return; -- 2.30.2