Received: by 10.192.165.156 with SMTP id m28csp25569imm; Tue, 10 Apr 2018 15:38:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/+BVCf2BzmyyVuop43CCMpn5Mvytoj2a+JPMBBo96W4H9CB97HLL+Sb+JK+v0nK4NJomEb X-Received: by 10.99.117.93 with SMTP id f29mr1538258pgn.197.1523399905364; Tue, 10 Apr 2018 15:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523399905; cv=none; d=google.com; s=arc-20160816; b=qDt5uzgTXDlR8pdkzOYLJZLahrFH3UPSaj25mZRqu5yKbJkYrSySkH9mPqaCkNgPMU KuFY2FSbYrwx6sM0HSoe9wnxAzP7BOc2DANolfCXS//JILrXmGjwJxBFURNnoI8gNyRg mA7dn6Nu1pbycBOUCOET+gBnPlJXa6VJPNuWfa95yy7Bqh0wnNxo9Kmsvtbx19JlzKQ1 y5yBzGfnKJOnZ/OQ/cTN9aGHMaglvYbRDv+KzJVm9WZl4Hm3HXhW7Btb4/RY1FyCSTbK ipJ43TUmEfuhjacdBD6gQacNu8c0ojwIwx+WCUuMS8JXOnBB5YfqfwsAU//V2MNdRXlC OP6w== 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=gYFx7vn4qWH/bHoYEedcC4Zj3PHaeocBxhR6yBjYtlI=; b=CzZ80K0qWqZtKi+/XdcPvjilrX9BmIcGxonL7NAb9qcNkuQKUVceMzVdKTo4bnnFys 1kMfZVyTcx80sbotfLViUqxtZQvwwELJycHLrV6x9UXyuZH5b6ADQ5gv9XW0dmaEU3b9 04HYYDTbJ0Oo9SxePxniR5I9dnvfVj5T7qsgRQu7SfpCh/2YLJuNskfj8BZsh5EGuNFK PlK3QCd2hESjSHIA+pnXSaacIxZfmEAqodmZsFOj4ziqCNJSOkAMR6dN6XVCEltcEIM/ 9V3AbRZtV73Pmh2RG6hcnDnb9vYLVpb68HF8GQ/epzF104/6SCNW4UsX6Vkp9cskNZr5 8kyg== 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 z62si2794644pfb.305.2018.04.10.15.37.48; Tue, 10 Apr 2018 15:38:25 -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 S1752820AbeDJWaV (ORCPT + 99 others); Tue, 10 Apr 2018 18:30:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39938 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754534AbeDJWaT (ORCPT ); Tue, 10 Apr 2018 18:30:19 -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 39A90DCB; Tue, 10 Apr 2018 22:30:18 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Yi , Ming Lei , Jens Axboe , Sasha Levin Subject: [PATCH 4.15 081/168] blk-mq: fix kernel oops in blk_mq_tag_idle() Date: Wed, 11 Apr 2018 00:23:43 +0200 Message-Id: <20180410212803.727989215@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: Ming Lei [ Upstream commit 8ab0b7dc73e1b3e2987d42554b2bff503f692772 ] HW queues may be unmapped in some cases, such as blk_mq_update_nr_hw_queues(), then we need to check it before calling blk_mq_tag_idle(), otherwise the following kernel oops can be triggered, so fix it by checking if the hw queue is unmapped since it doesn't make sense to idle the tags any more after hw queues are unmapped. [ 440.771298] Workqueue: nvme-wq nvme_rdma_del_ctrl_work [nvme_rdma] [ 440.779104] task: ffff894bae755ee0 ti: ffff893bf9bc8000 task.ti: ffff893bf9bc8000 [ 440.788359] RIP: 0010:[] [] __blk_mq_tag_idle+0x24/0x40 [ 440.798697] RSP: 0018:ffff893bf9bcbd10 EFLAGS: 00010286 [ 440.805538] RAX: 0000000000000000 RBX: ffff895bb131dc00 RCX: 000000000000011f [ 440.814426] RDX: 00000000ffffffff RSI: 0000000000000120 RDI: ffff895bb131dc00 [ 440.823301] RBP: ffff893bf9bcbd10 R08: 000000000001b860 R09: 4a51d361c00c0000 [ 440.832193] R10: b5907f32b4cc7003 R11: ffffd6cabfb57000 R12: ffff894bafd1e008 [ 440.841091] R13: 0000000000000001 R14: ffff895baf770000 R15: 0000000000000080 [ 440.849988] FS: 0000000000000000(0000) GS:ffff894bbdcc0000(0000) knlGS:0000000000000000 [ 440.859955] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 440.867274] CR2: 0000000000000008 CR3: 000000103d098000 CR4: 00000000001407e0 [ 440.876169] Call Trace: [ 440.879818] [] blk_mq_exit_hctx+0xd8/0xe0 [ 440.887051] [] blk_mq_free_queue+0xf0/0x160 [ 440.894465] [] blk_cleanup_queue+0xd9/0x150 [ 440.901881] [] nvme_ns_remove+0x5b/0xb0 [nvme_core] [ 440.910068] [] nvme_remove_namespaces+0x3b/0x60 [nvme_core] [ 440.919026] [] __nvme_rdma_remove_ctrl+0x2b/0xb0 [nvme_rdma] [ 440.928079] [] nvme_rdma_del_ctrl_work+0x17/0x20 [nvme_rdma] [ 440.937126] [] process_one_work+0x17a/0x440 [ 440.944517] [] worker_thread+0x278/0x3c0 [ 440.951607] [] ? manage_workers.isra.24+0x2a0/0x2a0 [ 440.959760] [] kthread+0xcf/0xe0 [ 440.966055] [] ? insert_kthread_work+0x40/0x40 [ 440.973715] [] ret_from_fork+0x58/0x90 [ 440.980586] [] ? insert_kthread_work+0x40/0x40 [ 440.988229] Code: 5b 41 5c 5d c3 66 90 0f 1f 44 00 00 48 8b 87 20 01 00 00 f0 0f ba 77 40 01 19 d2 85 d2 75 08 c3 0f 1f 80 00 00 00 00 55 48 89 e5 ff 48 08 48 8d 78 10 e8 7f 0f 05 00 5d c3 0f 1f 00 66 2e 0f [ 441.011620] RIP [] __blk_mq_tag_idle+0x24/0x40 [ 441.019301] RSP [ 441.024052] CR2: 0000000000000008 Reported-by: Zhang Yi Tested-by: Zhang Yi Signed-off-by: Ming Lei Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- block/blk-mq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1996,7 +1996,8 @@ static void blk_mq_exit_hctx(struct requ { blk_mq_debugfs_unregister_hctx(hctx); - blk_mq_tag_idle(hctx); + if (blk_mq_hw_queue_mapped(hctx)) + blk_mq_tag_idle(hctx); if (set->ops->exit_request) set->ops->exit_request(set, hctx->fq->flush_rq, hctx_idx);