From patchwork Wed Feb 1 06:36:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tahsin Erdogan X-Patchwork-Id: 9548929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9B4C9604A7 for ; Wed, 1 Feb 2017 06:37:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D36628384 for ; Wed, 1 Feb 2017 06:37:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 821EE2840E; Wed, 1 Feb 2017 06:37:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24BAC28401 for ; Wed, 1 Feb 2017 06:37:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751417AbdBAGhm (ORCPT ); Wed, 1 Feb 2017 01:37:42 -0500 Received: from mail-pf0-f179.google.com ([209.85.192.179]:34863 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751004AbdBAGhl (ORCPT ); Wed, 1 Feb 2017 01:37:41 -0500 Received: by mail-pf0-f179.google.com with SMTP id f144so116200111pfa.2 for ; Tue, 31 Jan 2017 22:37:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=xKFUzGVjH7z3JaGrWtvORm9V7tuslIjJ+sJ0geywGgw=; b=dmZLYTFmVIJV/AXsl2G5C+s7FrRFF3sdlDN7eYJ/CDq9ZZqR/gwn9s0o1udaOXPUf8 0ZHh8LoIyNbJ4vnTdNalhl3u8/0Ew+SGAb5YSx1weky48o5bxPSxZWtEz4jdL7FytL0l M6xgxijvmnT3cs5C4pnNVQgkzsU0/Swn+6SehVuPJRP3QsC+xWS9wbDc9hbufWFtSlII NZIb18NcnWzsirKK1Tn7YnfwKOK+aXYu7HsAzY59Y3LBrwT3mpJksmZhBUvFaLC8dxYI wXyy8sEp/AiKVGDxknzxHY+yZxU/2jN0TlmT9ODYmlm+a8T1IWKQAqrfTEH650WtBZh7 yldA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xKFUzGVjH7z3JaGrWtvORm9V7tuslIjJ+sJ0geywGgw=; b=X2ifPHh58n4dDRapzFGBLmFM4Vti4f3PyYuzXKOP7fJxF4EN/kj169EeXunY8QA2xC 3+Ec/IA1ir8pILy3UscCJNXX5d6YJM4tRQdFgFSFqf0NKKp8Q6P7vMtPDhJunZNf8Dr7 RLGfRmxcUiFKbUGtaVPYgVoSpgkbnIaQZkx20IENRtn0YzxJUgNdQkK3MfTeFvO77J0g Agm+/NIKjSZbHG6TjR1GmOH/vposrDbuyZGJeJnMEHFY3RffYqgks7UobQomzlDTvS47 a/maEdbk74i+t6GPNh8xTVL5PgZ6og6geMXRqahGAF7BMcHBRykfxDurv55xJP2UOooH vrGw== X-Gm-Message-State: AIkVDXKf/Ce8DnmU5hufde0zz0RJaur7LeP0etDw6bmE2XspGllc3a79Q6RSMm7klSM/tz8o X-Received: by 10.98.86.68 with SMTP id k65mr1598884pfb.13.1485931055932; Tue, 31 Jan 2017 22:37:35 -0800 (PST) Received: from tahsin1.mtv.corp.google.com ([100.99.140.90]) by smtp.gmail.com with ESMTPSA id o18sm46444760pgn.36.2017.01.31.22.37.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Jan 2017 22:37:35 -0800 (PST) From: Tahsin Erdogan To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Tahsin Erdogan Subject: [PATCH] block: queue lock must be acquired when iterating over rls Date: Tue, 31 Jan 2017 22:36:50 -0800 Message-Id: <20170201063650.15060-1-tahsin@google.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP blk_set_queue_dying() does not acquire queue lock before it calls blk_queue_for_each_rl(). This allows a racing blkg_destroy() to remove blkg->q_node from the linked list and have blk_queue_for_each_rl() loop infitely over the removed blkg->q_node list node. Signed-off-by: Tahsin Erdogan --- block/blk-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index 61ba08c58b64..0488a2b55bf0 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -525,12 +525,14 @@ void blk_set_queue_dying(struct request_queue *q) else { struct request_list *rl; + spin_lock_irq(q->queue_lock); blk_queue_for_each_rl(rl, q) { if (rl->rq_pool) { wake_up(&rl->wait[BLK_RW_SYNC]); wake_up(&rl->wait[BLK_RW_ASYNC]); } } + spin_unlock_irq(q->queue_lock); } } EXPORT_SYMBOL_GPL(blk_set_queue_dying);