[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH 09/14] block-backend: Fix potential double blk_d
From: |
Fam Zheng |
Subject: |
Re: [Qemu-block] [PATCH 09/14] block-backend: Fix potential double blk_delete() |
Date: |
Tue, 11 Sep 2018 16:27:46 +0800 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Fri, 09/07 18:15, Kevin Wolf wrote:
> blk_unref() first decreases the refcount of the BlockBackend and calls
> blk_delete() if the refcount reaches zero. Requests can still be in
> flight at this point, they are only drained during blk_delete():
>
> At this point, arbitrary callbacks can run. If any callback takes a
> temporary BlockBackend reference, it will first increase the refcount to
> 1 and then decrease it to 0 again, triggering another blk_delete(). This
> will cause a use-after-free crash in the outer blk_delete().
>
> Fix it by draining the BlockBackend before decreasing to refcount to 0.
> Assert in blk_ref() that it never takes the first refcount (which would
> mean that the BlockBackend is already being deleted).
>
> Signed-off-by: Kevin Wolf <address@hidden>
Good one!
Reviewed-by: Fam Zheng <address@hidden>
- [Qemu-block] [PATCH 05/14] test-bdrv-drain: Test AIO_WAIT_WHILE() in completion callback, (continued)
[Qemu-block] [PATCH 08/14] block-backend: Add .drained_poll callback, Kevin Wolf, 2018/09/07
[Qemu-block] [PATCH 09/14] block-backend: Fix potential double blk_delete(), Kevin Wolf, 2018/09/07
- Re: [Qemu-block] [PATCH 09/14] block-backend: Fix potential double blk_delete(),
Fam Zheng <=
[Qemu-block] [PATCH 12/14] blockjob: Lie better in child_job_drained_poll(), Kevin Wolf, 2018/09/07
[Qemu-block] [PATCH 10/14] block-backend: Decrease in_flight only after callback, Kevin Wolf, 2018/09/07
[Qemu-block] [PATCH 11/14] mirror: Fix potential use-after-free in active commit, Kevin Wolf, 2018/09/07
[Qemu-block] [PATCH 13/14] block: Remove aio_poll() in bdrv_drain_poll variants, Kevin Wolf, 2018/09/07
[Qemu-block] [PATCH 14/14] test-bdrv-drain: Test nested poll in bdrv_drain_poll_top_level(), Kevin Wolf, 2018/09/07