Received: by 10.192.165.156 with SMTP id m28csp27218imm; Tue, 10 Apr 2018 15:40:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx48DGoUNudQBuF0kpe4kGUnKuNLOi8szDsT5iFH+T6Ufs7nrTbh+Fjp3bDXdKNaYtDyj2Dr8 X-Received: by 2002:a17:902:f64:: with SMTP id 91-v6mr2274823ply.397.1523400051097; Tue, 10 Apr 2018 15:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523400051; cv=none; d=google.com; s=arc-20160816; b=qSJ1NQ3l+VDj4Cveh1n85M73vuBl1BPumfZi5HKIUA/f0lUjA7MUdpJMfqDRUkAGU1 utZOdXZ1RzprkAvstO7TGtQG/1HKJnhSsVcCBq+9KsynxDWJcMsd1fEv/fp2wJRctGiy FhZT/IowBP5HaMjQ00246WGudJh1WSNgq3dQ7kg4/cuUIxHuxV6ZGIG3SmWAtF+izG9u B5X5veCjuPK7nSIwzyn6MKbW5t/alDC/Kz2yS700BUA2SKi//gf31RuQMvSbSnWA1arY Z79dXa+A+B0DwERT8z8K6SewS5k+KlzJ4VQqXZR3cIbCgVBEe4mT3yuUXHlq6zzV5sx7 X78A== 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=rhHNYAWpho5gnkdWm/xixr7Pu/EWicCEKaiUg6e/S8M=; b=A9TbK1QKG5QlhTTDTrJkEPnanXZamvb3MIV32vN2sHDaZLc3yZ0GFfXKQxlfxO11kM sLEZ0lw8zvsH2ncewRjmugnROpWOeA+ZVrrIOFXxrvH71z7Dc0gwJvID82JZTJq4/xk5 W3Hc8E/pYffijOLvgxQSOfaM8UOOf79s+E9fCi2WAMsvA81lG1JaWemMtVf8o30Lk5bb /Qy7jZTVQlzggrOP+HOMp0Q++YAGJOzIKkRfWxBYx9cVx0Vp8AH+JBokIxHNwm6W0Dmt h46g9U0etUkSLsrcpMcfzNPOeNS4yP8ob0SjG63c+uusbevoXizt9hHoLF86qk0f7zEn HDtA== 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 m37-v6si3546543pla.346.2018.04.10.15.40.14; Tue, 10 Apr 2018 15:40:51 -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 S1755641AbeDJWge (ORCPT + 99 others); Tue, 10 Apr 2018 18:36:34 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42924 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932385AbeDJWgb (ORCPT ); Tue, 10 Apr 2018 18:36: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 BD4CFE02; Tue, 10 Apr 2018 22:36:23 +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.14 063/138] blk-mq: fix kernel oops in blk_mq_tag_idle() Date: Wed, 11 Apr 2018 00:24:13 +0200 Message-Id: <20180410212909.431889718@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: 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 @@ -1928,7 +1928,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);