Kevin Wolf 5ca9d21bd1 block-backend: Fix potential double blk_delete()
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 <kwolf@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
2018-09-25 15:50:15 +02:00
..
2018-07-10 16:01:52 +02:00
2018-08-31 16:28:33 +02:00
2018-08-15 12:50:39 +02:00
2018-07-05 10:29:19 +02:00
2018-08-15 12:50:39 +02:00
2018-08-15 10:12:35 +08:00
2018-07-10 17:28:29 +01:00
2018-07-30 15:35:37 +02:00
2018-08-15 12:50:39 +02:00
2018-07-10 16:01:52 +02:00
2018-07-02 14:45:23 +02:00