|
|
357786 |
From b8f1b4c9b03d2ec06ed69d0f6769499d197eccd8 Mon Sep 17 00:00:00 2001
|
|
|
357786 |
From: John Snow <jsnow@redhat.com>
|
|
|
357786 |
Date: Tue, 24 Jul 2018 12:50:06 +0200
|
|
|
357786 |
Subject: [PATCH 65/89] block: Fix parameter checking in
|
|
|
357786 |
bdrv_co_copy_range_internal
|
|
|
357786 |
|
|
|
357786 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
357786 |
Message-id: <20180718225511.14878-15-jsnow@redhat.com>
|
|
|
357786 |
Patchwork-id: 81411
|
|
|
357786 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 14/35] block: Fix parameter checking in bdrv_co_copy_range_internal
|
|
|
357786 |
Bugzilla: 1207657
|
|
|
357786 |
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
|
357786 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
357786 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
From: Fam Zheng <famz@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
src may be NULL if BDRV_REQ_ZERO_WRITE flag is set, in this case only
|
|
|
357786 |
check dst and dst->bs. This bug was introduced when moving in the
|
|
|
357786 |
request tracking code from bdrv_co_copy_range, in 37aec7d75eb.
|
|
|
357786 |
|
|
|
357786 |
This especially fixes the possible segfault when initializing src_bs
|
|
|
357786 |
with a NULL src.
|
|
|
357786 |
|
|
|
357786 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
357786 |
Message-id: 20180703023758.14422-2-famz@redhat.com
|
|
|
357786 |
Reviewed-by: Jeff Cody <jcody@redhat.com>
|
|
|
357786 |
Signed-off-by: Jeff Cody <jcody@redhat.com>
|
|
|
357786 |
(cherry picked from commit d4d3e5a0d53a57282955e8a3ed7acc1ca90552d9)
|
|
|
357786 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
357786 |
---
|
|
|
357786 |
block/io.c | 28 +++++++++++++++-------------
|
|
|
357786 |
1 file changed, 15 insertions(+), 13 deletions(-)
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/io.c b/block/io.c
|
|
|
357786 |
index 136a5d0..7981239 100644
|
|
|
357786 |
--- a/block/io.c
|
|
|
357786 |
+++ b/block/io.c
|
|
|
357786 |
@@ -2848,17 +2848,11 @@ static int coroutine_fn bdrv_co_copy_range_internal(BdrvChild *src,
|
|
|
357786 |
bool recurse_src)
|
|
|
357786 |
{
|
|
|
357786 |
BdrvTrackedRequest src_req, dst_req;
|
|
|
357786 |
- BlockDriverState *src_bs = src->bs;
|
|
|
357786 |
- BlockDriverState *dst_bs = dst->bs;
|
|
|
357786 |
int ret;
|
|
|
357786 |
|
|
|
357786 |
- if (!src || !dst || !src->bs || !dst->bs) {
|
|
|
357786 |
+ if (!dst || !dst->bs) {
|
|
|
357786 |
return -ENOMEDIUM;
|
|
|
357786 |
}
|
|
|
357786 |
- ret = bdrv_check_byte_request(src->bs, src_offset, bytes);
|
|
|
357786 |
- if (ret) {
|
|
|
357786 |
- return ret;
|
|
|
357786 |
- }
|
|
|
357786 |
|
|
|
357786 |
ret = bdrv_check_byte_request(dst->bs, dst_offset, bytes);
|
|
|
357786 |
if (ret) {
|
|
|
357786 |
@@ -2868,17 +2862,25 @@ static int coroutine_fn bdrv_co_copy_range_internal(BdrvChild *src,
|
|
|
357786 |
return bdrv_co_pwrite_zeroes(dst, dst_offset, bytes, flags);
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
+ if (!src || !src->bs) {
|
|
|
357786 |
+ return -ENOMEDIUM;
|
|
|
357786 |
+ }
|
|
|
357786 |
+ ret = bdrv_check_byte_request(src->bs, src_offset, bytes);
|
|
|
357786 |
+ if (ret) {
|
|
|
357786 |
+ return ret;
|
|
|
357786 |
+ }
|
|
|
357786 |
+
|
|
|
357786 |
if (!src->bs->drv->bdrv_co_copy_range_from
|
|
|
357786 |
|| !dst->bs->drv->bdrv_co_copy_range_to
|
|
|
357786 |
|| src->bs->encrypted || dst->bs->encrypted) {
|
|
|
357786 |
return -ENOTSUP;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
- bdrv_inc_in_flight(src_bs);
|
|
|
357786 |
- bdrv_inc_in_flight(dst_bs);
|
|
|
357786 |
- tracked_request_begin(&src_req, src_bs, src_offset,
|
|
|
357786 |
+ bdrv_inc_in_flight(src->bs);
|
|
|
357786 |
+ bdrv_inc_in_flight(dst->bs);
|
|
|
357786 |
+ tracked_request_begin(&src_req, src->bs, src_offset,
|
|
|
357786 |
bytes, BDRV_TRACKED_READ);
|
|
|
357786 |
- tracked_request_begin(&dst_req, dst_bs, dst_offset,
|
|
|
357786 |
+ tracked_request_begin(&dst_req, dst->bs, dst_offset,
|
|
|
357786 |
bytes, BDRV_TRACKED_WRITE);
|
|
|
357786 |
|
|
|
357786 |
wait_serialising_requests(&src_req);
|
|
|
357786 |
@@ -2896,8 +2898,8 @@ static int coroutine_fn bdrv_co_copy_range_internal(BdrvChild *src,
|
|
|
357786 |
}
|
|
|
357786 |
tracked_request_end(&src_req);
|
|
|
357786 |
tracked_request_end(&dst_req);
|
|
|
357786 |
- bdrv_dec_in_flight(src_bs);
|
|
|
357786 |
- bdrv_dec_in_flight(dst_bs);
|
|
|
357786 |
+ bdrv_dec_in_flight(src->bs);
|
|
|
357786 |
+ bdrv_dec_in_flight(dst->bs);
|
|
|
357786 |
return ret;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
--
|
|
|
357786 |
1.8.3.1
|
|
|
357786 |
|