cf91b1d
From: Peter Lieven <pl@kamp.de>
cf91b1d
Date: Tue, 24 May 2016 10:59:28 +0200
cf91b1d
Subject: [PATCH] block/iscsi: avoid potential overflow of acb->task->cdb
cf91b1d
cf91b1d
at least in the path via virtio-blk the maximum size is not
cf91b1d
restricted.
cf91b1d
cf91b1d
Cc: qemu-stable@nongnu.org
cf91b1d
Signed-off-by: Peter Lieven <pl@kamp.de>
cf91b1d
Message-Id: <1464080368-29584-1-git-send-email-pl@kamp.de>
cf91b1d
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
cf91b1d
(cherry picked from commit a6b3167fa0e825aebb5a7cd8b437b6d41584a196)
cf91b1d
---
cf91b1d
 block/iscsi.c | 7 +++++++
cf91b1d
 1 file changed, 7 insertions(+)
cf91b1d
cf91b1d
diff --git a/block/iscsi.c b/block/iscsi.c
cf91b1d
index 302baf8..172e6cf 100644
cf91b1d
--- a/block/iscsi.c
cf91b1d
+++ b/block/iscsi.c
cf91b1d
@@ -837,6 +837,13 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs,
cf91b1d
         return &acb->common;
cf91b1d
     }
cf91b1d
 
cf91b1d
+    if (acb->ioh->cmd_len > SCSI_CDB_MAX_SIZE) {
cf91b1d
+        error_report("iSCSI: ioctl error CDB exceeds max size (%d > %d)",
cf91b1d
+                     acb->ioh->cmd_len, SCSI_CDB_MAX_SIZE);
cf91b1d
+        qemu_aio_unref(acb);
cf91b1d
+        return NULL;
cf91b1d
+    }
cf91b1d
+
cf91b1d
     acb->task = malloc(sizeof(struct scsi_task));
cf91b1d
     if (acb->task == NULL) {
cf91b1d
         error_report("iSCSI: Failed to allocate task for scsi command. %s",