[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 31/56] iscsi: assert that sectors are aligned to LUN
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 31/56] iscsi: assert that sectors are aligned to LUN blocksize |
Date: |
Tue, 13 Aug 2013 10:10:55 -0500 |
From: Peter Lieven <address@hidden>
if the blocksize of an iSCSI LUN is bigger than the BDRV_SECTOR_SIZE
it is possible that sector_num or nb_sectors are not correctly
aligned.
to avoid corruption we fail requests which are misaligned.
Signed-off-by: Peter Lieven <address@hidden>
Cc: address@hidden
Signed-off-by: Paolo Bonzini <address@hidden>
(cherry picked from commit 91bea4e2bb1a5f7954a3b3a4f2e28e96bd25c458)
Signed-off-by: Michael Roth <address@hidden>
---
block/iscsi.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/block/iscsi.c b/block/iscsi.c
index df283ed..1294fdf 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -237,6 +237,18 @@ static int64_t sector_qemu2lun(int64_t sector, IscsiLun
*iscsilun)
return sector * BDRV_SECTOR_SIZE / iscsilun->block_size;
}
+static bool is_request_lun_aligned(int64_t sector_num, int nb_sectors,
+ IscsiLun *iscsilun)
+{
+ if ((sector_num * BDRV_SECTOR_SIZE) % iscsilun->block_size ||
+ (nb_sectors * BDRV_SECTOR_SIZE) % iscsilun->block_size) {
+ error_report("iSCSI misaligned request: iscsilun->block_size %u,
sector_num %ld, nb_sectors %d",
+ iscsilun->block_size, sector_num, nb_sectors);
+ return 0;
+ }
+ return 1;
+}
+
static int
iscsi_aio_writev_acb(IscsiAIOCB *acb)
{
@@ -321,6 +333,10 @@ iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num,
IscsiLun *iscsilun = bs->opaque;
IscsiAIOCB *acb;
+ if (!is_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {
+ return NULL;
+ }
+
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
trace_iscsi_aio_writev(iscsilun->iscsi, sector_num, nb_sectors, opaque,
acb);
@@ -452,6 +468,10 @@ iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num,
IscsiLun *iscsilun = bs->opaque;
IscsiAIOCB *acb;
+ if (!is_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {
+ return NULL;
+ }
+
acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque);
trace_iscsi_aio_readv(iscsilun->iscsi, sector_num, nb_sectors, opaque,
acb);
--
1.7.9.5
- [Qemu-devel] [PATCH 21/56] target-moxie: gen_intermediate_code_internal() should be inlined, (continued)
- [Qemu-devel] [PATCH 21/56] target-moxie: gen_intermediate_code_internal() should be inlined, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 22/56] target-xtensa: gen_intermediate_code_internal() should be inlined, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 23/56] block: fix bdrv_flush() ordering in bdrv_close(), Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 24/56] target-openrisc: Fix typename in openrisc_cpu_class_by_name(), Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 25/56] qom: Fix class cast of NULL classes, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 29/56] iscsi: fix -ENOSPC in iscsi_create(), Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 26/56] seccomp: add the asynchronous I/O syscalls to the whitelist, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 27/56] qapi: qapi-commands: fix possible leaks on visitor dealloc, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 30/56] iscsi: remove support for misaligned nb_sectors in aio_readv, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 28/56] ahci: Fix FLUSH command, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 31/56] iscsi: assert that sectors are aligned to LUN blocksize,
Michael Roth <=
- [Qemu-devel] [PATCH 35/56] megasas: Legacy command line handling fix, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 39/56] xhci: handle USB_RET_IOERROR, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 34/56] cpus: Let vm_stop[_force_state]() always flush block devices, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 42/56] virtio-console: Use exitfn for virtserialport, too, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 40/56] qemu-char: Register ring buffer driver with correct name "ringbuf", Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 41/56] qapi: Rename ChardevBackend member "memory" to "ringbuf", Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 43/56] pci-bridge: update mappings for migration/restore, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 45/56] chardev: fix CHR_EVENT_OPENED events for mux chardevs, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 44/56] xhci: fix segfault, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 48/56] iov: handle EOF in iov_send_recv, Michael Roth, 2013/08/13