[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 25/41] luks: Turn invalid assertion into check
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 25/41] luks: Turn invalid assertion into check |
Date: |
Tue, 13 Mar 2018 17:17:47 +0100 |
The .bdrv_getlength implementation of the crypto block driver asserted
that the payload offset isn't after EOF. This is an invalid assertion to
make as the image file could be corrupted. Instead, check it and return
-EIO if the file is too small for the payload offset.
Zero length images are fine, so trigger -EIO only on offset > len, not
on offset >= len as the assertion did before.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Daniel P. Berrangé <address@hidden>
---
block/crypto.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/block/crypto.c b/block/crypto.c
index a1139b6f09..00fb40c631 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -518,7 +518,10 @@ static int64_t block_crypto_getlength(BlockDriverState *bs)
uint64_t offset = qcrypto_block_get_payload_offset(crypto->block);
assert(offset < INT64_MAX);
- assert(offset < len);
+
+ if (offset > len) {
+ return -EIO;
+ }
len -= offset;
--
2.13.6
- [Qemu-block] [PULL 24/41] luks: Support .bdrv_co_create, (continued)
- [Qemu-block] [PULL 24/41] luks: Support .bdrv_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 20/41] iotests: test manual job dismissal, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 12/41] blockjobs: ensure abort is called for cancelled jobs, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 15/41] blockjobs: add prepare callback, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 22/41] luks: Separate image file creation from formatting, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 29/41] vdi: Move file creation to vdi_co_create_opts, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 27/41] qemu-iotests: Test luks QMP image creation, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 26/41] luks: Catch integer overflow for huge sizes, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 19/41] blockjobs: Expose manual property, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 21/41] tests/test-blockjob: test cancellations, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 25/41] luks: Turn invalid assertion into check,
Kevin Wolf <=
- [Qemu-block] [PULL 34/41] qemu-iotests: Enable write tests for parallels, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 28/41] vdi: Pull option parsing from vdi_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 38/41] vhdx: Support .bdrv_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 30/41] vdi: Implement .bdrv_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 31/41] block: Fix flags in reopen queue, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 32/41] iotests: Add regression test for commit base locking, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 33/41] parallels: Support .bdrv_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 37/41] vdi: Make comments consistent with other drivers, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 35/41] qcow: Support .bdrv_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 36/41] qed: Support .bdrv_co_create, Kevin Wolf, 2018/03/13