linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Jan Kara <jack@suse.cz>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org,
	Dan Williams <dan.j.williams@intel.com>,
	Omar Sandoval <osandov@osandov.com>,
	Arthur Marsh <arthur.marsh@internode.on.net>,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH 2/4] bdi: Fix use-after-free in wb_congested_put()
Date: Wed, 8 Mar 2017 17:56:51 -0500	[thread overview]
Message-ID: <20170308225651.GC21117@htj.duckdns.org> (raw)
In-Reply-To: <20170308164834.14302-3-jack@suse.cz>

On Wed, Mar 08, 2017 at 05:48:32PM +0100, Jan Kara wrote:
> bdi_writeback_congested structures get created for each blkcg and bdi
> regardless whether bdi is registered or not. When they are created in
> unregistered bdi and the request queue (and thus bdi) is then destroyed
> while blkg still holds reference to bdi_writeback_congested structure,
> this structure will be referencing freed bdi and last wb_congested_put()
> will try to remove the structure from already freed bdi.
> 
> With commit 165a5e22fafb "block: Move bdi_unregister() to
> del_gendisk()", SCSI started to destroy bdis without calling
> bdi_unregister() first (previously it was calling bdi_unregister() even
> for unregistered bdis) and thus the code detaching
> bdi_writeback_congested in cgwb_bdi_destroy() was not triggered and we
> started hitting this use-after-free bug. It is enough to boot a KVM
> instance with virtio-scsi device to trigger this behavior.
> 
> Fix the problem by detaching bdi_writeback_congested structures in
> bdi_exit() instead of bdi_unregister(). This is also more logical as
> they can get attached to bdi regardless whether it ever got registered
> or not.
> 
> Fixes: 165a5e22fafb127ecb5914e12e8c32a1f0d3f820
> Signed-off-by: Jan Kara <jack@suse.cz>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

  reply	other threads:[~2017-03-08 22:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-08 16:48 [PATCH 0/4] block: Fixes for bdi handling Jan Kara
2017-03-08 16:48 ` [PATCH 1/4] block: Allow bdi re-registration Jan Kara
2017-03-08 22:55   ` Tejun Heo
2017-03-08 23:17     ` James Bottomley
2017-03-09  9:10     ` Jan Kara
2017-03-08 16:48 ` [PATCH 2/4] bdi: Fix use-after-free in wb_congested_put() Jan Kara
2017-03-08 22:56   ` Tejun Heo [this message]
2017-03-08 16:48 ` [PATCH 3/4] block: Make del_gendisk() safer for disks without queues Jan Kara
2017-03-08 22:57   ` Tejun Heo
2017-03-08 16:48 ` [PATCH 4/4] Revert "scsi, block: fix duplicate bdi name registration crashes" Jan Kara
2017-03-08 17:12   ` Dan Williams
2017-03-08 16:50 ` [PATCH 0/4] block: Fixes for bdi handling Omar Sandoval
2017-03-08 17:39   ` Omar Sandoval
2017-03-08 16:55 ` Jens Axboe
2017-03-09  9:05 ` Arthur Marsh
2017-03-09 10:16 [PATCH 0/4 v2] " Jan Kara
2017-03-09 10:16 ` [PATCH 2/4] bdi: Fix use-after-free in wb_congested_put() Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170308225651.GC21117@htj.duckdns.org \
    --to=tj@kernel.org \
    --cc=arthur.marsh@internode.on.net \
    --cc=axboe@kernel.dk \
    --cc=dan.j.williams@intel.com \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=osandov@osandov.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).