Received: by 10.213.65.68 with SMTP id h4csp742078imn; Fri, 6 Apr 2018 08:09:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+3FdRXSDcMA+QgrIPXA2NWAv28KzsO5LdWJUcdX7ejiM1WYhGqPjTWSoPC8Q/qip0kDJKo X-Received: by 2002:a17:902:a501:: with SMTP id s1-v6mr27878179plq.201.1523027351717; Fri, 06 Apr 2018 08:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523027351; cv=none; d=google.com; s=arc-20160816; b=EbALxvLSjhF4HR1CsdMZPjZwtQ5wvuISGdHOlxSGcExuZrkSK2vgOuJwbA7xJsuHLf uQzKnPz+8jUqg6Cbnl5MsofOwyXWa+hkjwSLN9FT9t3s5LzD+belAtrH06ve3lqQ/g3j SfxznrlEuzSKh4NEvu9ke/dKc1YdHvB1+ET5xqaCSNBCSdrf31XGzw2AB/fbGUUSK10r 53muLiMdHMOgHxEtWDFPDdwkn1KFojTu+mJ1zbcu5XhglSDqz6v40f7NdRfxKNdQisZs X8PVBGrrpeKYTB6bebL4jbBM30ECUjn2XcontEikT7hSlm9ppoAYFCROgTJCzbjdJ/Rj S7lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:to:from:date:dkim-signature :arc-authentication-results; bh=j41Ybz+SujReRFFrtA2hus3batPBhCeTThVsguqDTO8=; b=RVteBviUxk/p0aSnRi75CAs7xL3IW6Lt0ZwR6Uqox9OP1kHAT5QP8YU0ev/kVIpM8z TsOczKWVsSBeA2Ew9coMst9Tyifb8PPRDLEdNqh1fqV/J1Y7CteGB3OITwG0gjqJWxVj MKipwW+Y02DxmCsRBZqDcWipqD3amZKqnRRRMNyUr7LaCijAfxc7IYl2syM/QTfX7kna ZUj2NaBycxTs1qAU6PNj4zhzTK9WOAPFGFXp7IRcQr1hfwmwwZ4zW8fVk4OdJC1aRZZN BCrKHafcuKBz3NnrIeqFb2zQkJA5PstWc7631SMZxZF6JGk8LluSQJPkBpy1eZhVtpvp aFUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WG2rFGZ1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b35-v6si8808616plh.84.2018.04.06.08.08.57; Fri, 06 Apr 2018 08:09:11 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WG2rFGZ1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755189AbeDFPHB (ORCPT + 99 others); Fri, 6 Apr 2018 11:07:01 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:36642 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754793AbeDFPG7 (ORCPT ); Fri, 6 Apr 2018 11:06:59 -0400 Received: by mail-wr0-f195.google.com with SMTP id y55so2090137wry.3; Fri, 06 Apr 2018 08:06:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=j41Ybz+SujReRFFrtA2hus3batPBhCeTThVsguqDTO8=; b=WG2rFGZ1npFiEEiRBJ3lEKojLWvRD3JkQPd12ICh/dShZaChYUxEx1yGFPXokyc4+w 1IfgTsdQHNbiHjvR4ucZh8jOQvqjyPMYuqMg9KgNV2fHemrFtzReYIXpvpNJ7a4at3nC 7vJA485aV+W2bePkuHGyUDoiL7Kd37fdxBJVf73fjdMLR0L91IPcoUC7jy78WcWppvBY 8RGe7UbB6jQj3hMp626XYt/J8vYsvKKnV1lqRrXlYs1QD28DAaokxIkhqGKz8ehtLRvp rOA9P/GDgDXHXoBcUu+wW6V6HdM85pUTey2D+xeiEqb3lnO0Gnn9wKn/Aj4fauFF7m/b 0q7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=j41Ybz+SujReRFFrtA2hus3batPBhCeTThVsguqDTO8=; b=atEyNVjMAZ9Lmj1lyoJf6jPMYYyIIXZUfhkaynAae8Ie6MkXgeY9OCyisk06pc+mGe 3tbjpfmiak4KsbNQFAbrRKVDMJaDO+jM53q03rs8FYfKZxs5HRbhiCcN1Ukqn819Aa4j xfGrzsuiJ+maoWSakCT6ijtLm9FT422QCUeWkxN8UAAiT28JQFvXh6ir/6j/nau5EUOQ Ts5fRRmOnD9e39vEepKJPTftgp39+q9B28g/d6DwYXtev2wOuBTwzsLFZDghF8zH/o64 smxX3V6znV974/3PEQCGcRRkMYPD44QV+y8SvBj4uKSMtfH3skyUwLaYufLrn61p+glq T0aQ== X-Gm-Message-State: AElRT7GhfrJsRUV21YmLgQ1SHSPrQnbVCdO7J4thS5V59ExljCOUeK3Z 0YQtPSUeGPc6tpQwDTGc0tQ= X-Received: by 10.223.129.199 with SMTP id 65mr19184885wra.159.1523027217653; Fri, 06 Apr 2018 08:06:57 -0700 (PDT) Received: from gmail.com (51B6C0F5.dsl.pool.telekom.hu. [81.182.192.245]) by smtp.gmail.com with ESMTPSA id t69sm19347581wrc.87.2018.04.06.08.06.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Apr 2018 08:06:56 -0700 (PDT) Date: Fri, 6 Apr 2018 17:06:50 +0200 From: Alexandru Moise <00moses.alexander00@gmail.com> To: axboe@kernel.dk, tj@kernel.org, shli@fb.com, pombredanne@nexb.com, gregkh@linuxfoundation.org, joseph.qi@linux.alibaba.com, nborisov@suse.com, arnd@arndb.de, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] blk-cgroup: remove entries in blkg_tree before queue release Message-ID: <20180406150648.GA6378@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The q->id is used as an index within the blkg_tree radix tree. If the entry is not released before reclaiming the blk_queue_ida's id blkcg_init_queue() within a different driver from which this id was originally for can fail due to the entry at that index within the radix tree already existing. Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com> --- block/blk-cgroup.c | 2 +- block/blk-sysfs.c | 4 ++++ include/linux/blk-cgroup.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 1c16694ae145..224e937dbb59 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -369,7 +369,7 @@ static void blkg_destroy(struct blkcg_gq *blkg) * * Destroy all blkgs associated with @q. */ -static void blkg_destroy_all(struct request_queue *q) +void blkg_destroy_all(struct request_queue *q) { struct blkcg_gq *blkg, *n; diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index d00d1b0ec109..a72866458f22 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -816,6 +816,10 @@ static void __blk_release_queue(struct work_struct *work) if (q->bio_split) bioset_free(q->bio_split); + spin_lock_irq(q->queue_lock); + blkg_destroy_all(q); + spin_unlock_irq(q->queue_lock); + ida_simple_remove(&blk_queue_ida, q->id); call_rcu(&q->rcu_head, blk_free_queue_rcu); } diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index 6c666fd7de3c..4470fdb6ea8f 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -179,6 +179,8 @@ struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg, int blkcg_init_queue(struct request_queue *q); void blkcg_drain_queue(struct request_queue *q); void blkcg_exit_queue(struct request_queue *q); +void blkg_destroy_all(struct request_queue *q); + /* Blkio controller policy registration */ int blkcg_policy_register(struct blkcg_policy *pol); -- 2.16.3