Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2041404imm; Mon, 16 Jul 2018 00:43:13 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfww34vRfOmHaqcHMbk+E1OCrjNfK/LjfEHWL5EhX5o0i7o2TZ706Stp8AK5XYY72LlhKHG X-Received: by 2002:a63:3d41:: with SMTP id k62-v6mr14657322pga.254.1531726993081; Mon, 16 Jul 2018 00:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531726993; cv=none; d=google.com; s=arc-20160816; b=nbt5PK0vjHogb/+Jzb7Gv/fx/jF5RAdsG+0ETZcDlrifSHFw0L6Eh9tImdvARWh0na jM/AfN1V2IhCub0Fxl5OvmR2FrwxSQpwIAIu/anXzQnbeISNlSVTuGmIBn+3GnVxf5Ec jgrz7vQJjxeJEUwDAnWc7bhSgr0z1YWCBXqLeEDcEiXR0jjaA0ozPpzwY8HDmJxZq/eP 6x5eOgkHGARUyZByoo53zDza0oqN/gI5nRbIiLFnJImqQlYFqB24JQHXp23FXreuhCrT RV7X1uFeXjtg5Ag5Z7eMnITEQBXOCLfodjfSQXgzub4KaKcuqI2x7DYdrC1CHXzmux/I eV4g== 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=gv4BKmz7d8KxkzeGE4LOxYUlmT1k6SjyCCgG6TTwfW8=; b=fSgdlQ8GPsYoaKXp66AJ5hFTsXs7dnP76/BA2qEpRjfdtV50LizAwfgBRDH0j9rRUw zQ7wFdrD1g246cHGqyKNwr96pdeRCRzGMSiMsKgJ068pNeXLVLyWhpqB3NRTYmW9vTyV hc6buN4YRnD1TGBseNPPD3kFPTh2zQwpmNmSona+k+JjUUZOjfkprMuf1eXlSZsVc5jh cDHVKnCbHcYWzX0dr7+4Id2ty3jyZBRVCZ6IebOQQx+7y8rtgZdqSsu0oxbCUSuToOzH QWGJrmwrNRRi0VWncf+R4jFVeveG8HcfpPGvFMTd9H3OIE1wsgvzZP7f9xByPeCjd3By djGA== 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 m9-v6si8327628pga.456.2018.07.16.00.42.58; Mon, 16 Jul 2018 00:43:13 -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 S2388750AbeGPII1 (ORCPT + 99 others); Mon, 16 Jul 2018 04:08:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47762 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730161AbeGPII0 (ORCPT ); Mon, 16 Jul 2018 04:08:26 -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 7E91CCA0; Mon, 16 Jul 2018 07:42:23 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Scott Bauer , Christoph Hellwig , Simon Veith , David Woodhouse , Amit Shah Subject: [PATCH 4.9 01/32] nvme: validate admin queue before unquiesce Date: Mon, 16 Jul 2018 09:36:09 +0200 Message-Id: <20180716073504.573716820@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073504.433996952@linuxfoundation.org> References: <20180716073504.433996952@linuxfoundation.org> User-Agent: quilt/0.65 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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Scott Bauer commit 7dd1ab163c17e11473a65b11f7e748db30618ebb upstream. With a misbehaving controller it's possible we'll never enter the live state and create an admin queue. When we fail out of reset work it's possible we failed out early enough without setting up the admin queue. We tear down queues after a failed reset, but needed to do some more sanitization. Fixes 443bd90f2cca: "nvme: host: unquiesce queue in nvme_kill_queues()" [ 189.650995] nvme nvme1: pci function 0000:0b:00.0 [ 317.680055] nvme nvme0: Device not ready; aborting reset [ 317.680183] nvme nvme0: Removing after probe failure status: -19 [ 317.681258] kasan: GPF could be caused by NULL-ptr deref or user memory access [ 317.681397] general protection fault: 0000 [#1] SMP KASAN [ 317.682984] CPU: 3 PID: 477 Comm: kworker/3:2 Not tainted 4.13.0-rc1+ #5 [ 317.683112] Hardware name: Gigabyte Technology Co., Ltd. Z170X-UD5/Z170X-UD5-CF, BIOS F5 03/07/2016 [ 317.683284] Workqueue: events nvme_remove_dead_ctrl_work [nvme] [ 317.683398] task: ffff8803b0990000 task.stack: ffff8803c2ef0000 [ 317.683516] RIP: 0010:blk_mq_unquiesce_queue+0x2b/0xa0 [ 317.683614] RSP: 0018:ffff8803c2ef7d40 EFLAGS: 00010282 [ 317.683716] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 1ffff1006fbdcde3 [ 317.683847] RDX: 0000000000000038 RSI: 1ffff1006f5a9245 RDI: 0000000000000000 [ 317.683978] RBP: ffff8803c2ef7d58 R08: 1ffff1007bcdc974 R09: 0000000000000000 [ 317.684108] R10: 1ffff1007bcdc975 R11: 0000000000000000 R12: 00000000000001c0 [ 317.684239] R13: ffff88037ad49228 R14: ffff88037ad492d0 R15: ffff88037ad492e0 [ 317.684371] FS: 0000000000000000(0000) GS:ffff8803de6c0000(0000) knlGS:0000000000000000 [ 317.684519] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 317.684627] CR2: 0000002d1860c000 CR3: 000000045b40d000 CR4: 00000000003406e0 [ 317.684758] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 317.684888] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 317.685018] Call Trace: [ 317.685084] nvme_kill_queues+0x4d/0x170 [nvme_core] [ 317.685185] nvme_remove_dead_ctrl_work+0x3a/0x90 [nvme] [ 317.685289] process_one_work+0x771/0x1170 [ 317.685372] worker_thread+0xde/0x11e0 [ 317.685452] ? pci_mmcfg_check_reserved+0x110/0x110 [ 317.685550] kthread+0x2d3/0x3d0 [ 317.685617] ? process_one_work+0x1170/0x1170 [ 317.685704] ? kthread_create_on_node+0xc0/0xc0 [ 317.685785] ret_from_fork+0x25/0x30 [ 317.685798] Code: 0f 1f 44 00 00 55 48 b8 00 00 00 00 00 fc ff df 48 89 e5 41 54 4c 8d a7 c0 01 00 00 53 48 89 fb 4c 89 e2 48 c1 ea 03 48 83 ec 08 <80> 3c 02 00 75 50 48 8b bb c0 01 00 00 e8 33 8a f9 00 0f ba b3 [ 317.685872] RIP: blk_mq_unquiesce_queue+0x2b/0xa0 RSP: ffff8803c2ef7d40 [ 317.685908] ---[ end trace a3f8704150b1e8b4 ]--- Signed-off-by: Scott Bauer Signed-off-by: Christoph Hellwig [ adapted for 4.9: added check around blk_mq_start_hw_queues() call instead of upstream blk_mq_unquiesce_queue() ] Fixes: 4aae4388165a2611fa42 ("nvme: fix hang in remove path") Signed-off-by: Simon Veith Signed-off-by: David Woodhouse Signed-off-by: Amit Shah Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2042,7 +2042,8 @@ void nvme_kill_queues(struct nvme_ctrl * mutex_lock(&ctrl->namespaces_mutex); /* Forcibly start all queues to avoid having stuck requests */ - blk_mq_start_hw_queues(ctrl->admin_q); + if (ctrl->admin_q) + blk_mq_start_hw_queues(ctrl->admin_q); list_for_each_entry(ns, &ctrl->namespaces, list) { /*