Fam Zheng 178bd438af block: Walk bs->children carefully in bdrv_drain_recurse
The recursive bdrv_drain_recurse may run a block job completion BH that
drops nodes. The coming changes will make that more likely and use-after-free
would happen without this patch

Stash the bs pointer and use bdrv_ref/bdrv_unref in addition to
QLIST_FOREACH_SAFE to prevent such a case from happening.

Since bdrv_unref accesses global state that is not protected by the AioContext
lock, we cannot use bdrv_ref/bdrv_unref unconditionally.  Fortunately the
protection is not needed in IOThread because only main loop can modify a graph
with the AioContext lock held.

Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170418143044.12187-2-famz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Tested-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
2017-04-18 22:56:28 +08:00
..
2016-01-20 13:36:23 +01:00
2017-03-31 15:53:22 -04:00
2016-10-07 14:14:06 +02:00
2016-10-07 14:14:06 +02:00
2017-04-11 15:33:00 +02:00
2017-04-04 11:40:55 +01:00
2017-04-03 17:11:40 +02:00
2016-11-25 13:51:30 +01:00
2016-06-07 18:19:24 +03:00
2016-01-20 13:36:23 +01:00
2016-01-20 13:36:23 +01:00
2017-03-17 12:54:06 +01:00
2016-09-23 11:42:52 +08:00