[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/26] qemu-img: Fix assert when mapping unaligned ra
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 01/26] qemu-img: Fix assert when mapping unaligned raw file |
Date: |
Fri, 15 Jun 2018 16:20:43 +0200 |
From: Eric Blake <address@hidden>
Commit a290f085 exposed a latent bug in qemu-img map introduced
during the conversion of block status to be byte-based. Earlier in
commit 5e344dd8, the internal interface get_block_status() switched
to take byte-based parameters, but still called a sector-based
block layer function; as such, rounding was added in the lone
caller to obey the contract. However, commit 237d78f8 changed
get_block_status() to truly be byte-based, at which point rounding
to sector boundaries can result in calling bdrv_block_status() with
'bytes == 0' (a coding error) when the boundary between data and a
hole falls mid-sector (true for the past-EOF implicit hole present
in POSIX files). Fix things by removing the rounding that is now
no longer necessary.
See also https://bugzilla.redhat.com/1589738
Fixes: 237d78f8
Reported-by: Dan Kenigsberg <address@hidden>
Reported-by: Nir Soffer <address@hidden>
Reported-by: Maor Lipchuk <address@hidden>
CC: address@hidden
Signed-off-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qemu-img.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qemu-img.c b/qemu-img.c
index 1dcdd47254..e1a506f7f6 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2906,7 +2906,7 @@ static int img_map(int argc, char **argv)
int64_t n;
/* Probe up to 1 GiB at a time. */
- n = QEMU_ALIGN_DOWN(MIN(1 << 30, length - offset), BDRV_SECTOR_SIZE);
+ n = MIN(1 << 30, length - offset);
ret = get_block_status(bs, offset, n, &next);
if (ret < 0) {
--
2.13.6
- [Qemu-devel] [PULL 00/26] Block layer patches, Kevin Wolf, 2018/06/15
- [Qemu-devel] [PULL 04/26] jobs: fix verb references in docs, Kevin Wolf, 2018/06/15
- [Qemu-devel] [PULL 01/26] qemu-img: Fix assert when mapping unaligned raw file,
Kevin Wolf <=
- [Qemu-devel] [PULL 03/26] jobs: fix stale wording, Kevin Wolf, 2018/06/15
- [Qemu-devel] [PULL 05/26] rbd: Drop deprecated -drive parameter "filename", Kevin Wolf, 2018/06/15
- [Qemu-devel] [PULL 06/26] iscsi: Drop deprecated -drive parameter "filename", Kevin Wolf, 2018/06/15
- [Qemu-devel] [PULL 02/26] iotests: Add test 221 to catch qemu-img map regression, Kevin Wolf, 2018/06/15
- [Qemu-devel] [PULL 07/26] block: Add block-specific QDict header, Kevin Wolf, 2018/06/15
- [Qemu-devel] [PULL 14/26] block-qdict: Simplify qdict_flatten_qdict(), Kevin Wolf, 2018/06/15
- [Qemu-devel] [PULL 10/26] block: Fix -drive for certain non-string scalars, Kevin Wolf, 2018/06/15
- [Qemu-devel] [PULL 12/26] block: Factor out qobject_input_visitor_new_flat_confused(), Kevin Wolf, 2018/06/15
- [Qemu-devel] [PULL 13/26] block: Make remaining uses of qobject input visitor more robust, Kevin Wolf, 2018/06/15
- [Qemu-devel] [PULL 15/26] block-qdict: Tweak qdict_flatten_qdict(), qdict_flatten_qlist(), Kevin Wolf, 2018/06/15