|
|
357786 |
From 24f8fe9543b18cc484fc43ac1bf5bd7780656fbd Mon Sep 17 00:00:00 2001
|
|
|
357786 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
Date: Fri, 14 Sep 2018 10:55:35 +0200
|
|
|
357786 |
Subject: [PATCH 44/49] mirror: Fix potential use-after-free in active commit
|
|
|
357786 |
|
|
|
357786 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
Message-id: <20180914105540.18077-38-kwolf@redhat.com>
|
|
|
357786 |
Patchwork-id: 82188
|
|
|
357786 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 37/42] mirror: Fix potential use-after-free in active commit
|
|
|
357786 |
Bugzilla: 1601212
|
|
|
357786 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
357786 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
357786 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
When starting an active commit job, other callbacks can run before
|
|
|
357786 |
mirror_start_job() calls bdrv_ref() where needed and cause the nodes to
|
|
|
357786 |
go away. Add another pair of bdrv_ref/unref() around it to protect
|
|
|
357786 |
against this case.
|
|
|
357786 |
|
|
|
357786 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
357786 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
357786 |
---
|
|
|
357786 |
block/mirror.c | 11 +++++++++++
|
|
|
357786 |
1 file changed, 11 insertions(+)
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/mirror.c b/block/mirror.c
|
|
|
357786 |
index 4b27f71..8658873 100644
|
|
|
357786 |
--- a/block/mirror.c
|
|
|
357786 |
+++ b/block/mirror.c
|
|
|
357786 |
@@ -1335,7 +1335,14 @@ void commit_active_start(const char *job_id, BlockDriverState *bs,
|
|
|
357786 |
|
|
|
357786 |
orig_base_flags = bdrv_get_flags(base);
|
|
|
357786 |
|
|
|
357786 |
+ /* bdrv_reopen() drains, which might make the BDSes go away before a
|
|
|
357786 |
+ * reference is taken in mirror_start_job(). */
|
|
|
357786 |
+ bdrv_ref(bs);
|
|
|
357786 |
+ bdrv_ref(base);
|
|
|
357786 |
+
|
|
|
357786 |
if (bdrv_reopen(base, bs->open_flags, errp)) {
|
|
|
357786 |
+ bdrv_unref(bs);
|
|
|
357786 |
+ bdrv_unref(base);
|
|
|
357786 |
return;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
@@ -1344,6 +1351,10 @@ void commit_active_start(const char *job_id, BlockDriverState *bs,
|
|
|
357786 |
on_error, on_error, true, cb, opaque,
|
|
|
357786 |
&commit_active_job_driver, false, base, auto_complete,
|
|
|
357786 |
filter_node_name, false, &local_err);
|
|
|
357786 |
+
|
|
|
357786 |
+ bdrv_unref(bs);
|
|
|
357786 |
+ bdrv_unref(base);
|
|
|
357786 |
+
|
|
|
357786 |
if (local_err) {
|
|
|
357786 |
error_propagate(errp, local_err);
|
|
|
357786 |
goto error_restore_flags;
|
|
|
357786 |
--
|
|
|
357786 |
1.8.3.1
|
|
|
357786 |
|