From f5596dffdad4014342239c7d3ec85e637969d2de Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Fri, 29 Jul 2016 07:54:22 +0200 Subject: [PATCH] block/iscsi: avoid potential overflow of acb->task->cdb RH-Author: Fam Zheng Message-id: <1469778862-32607-1-git-send-email-famz@redhat.com> Patchwork-id: 71515 O-Subject: [RHEL-7.2.z qemu-kvm PATCH] block/iscsi: avoid potential overflow of acb->task->cdb Bugzilla: 1358996 RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Laszlo Ersek RH-Acked-by: Laurent Vivier From: Peter Lieven at least in the path via virtio-blk the maximum size is not restricted. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Lieven Message-Id: <1464080368-29584-1-git-send-email-pl@kamp.de> Signed-off-by: Paolo Bonzini (cherry picked from commit a6b3167fa0e825aebb5a7cd8b437b6d41584a196) Conflicts: block/iscsi.c Upstream uses qemu_aio_unref, downstream uses qemu_aio_release. Also, context in conflict because downstream doesn't have 4bb17ab51 (iscsi: Emulate commands in iscsi_aio_ioctl as iscsi_ioctl). Signed-off-by: Fam Zheng Signed-off-by: Miroslav Rezanina --- block/iscsi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/iscsi.c b/block/iscsi.c index 92dc1dd..d472ee8 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -698,6 +698,13 @@ static BlockDriverAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, acb->buf = NULL; acb->ioh = buf; + if (acb->ioh->cmd_len > SCSI_CDB_MAX_SIZE) { + error_report("iSCSI: ioctl error CDB exceeds max size (%d > %d)", + acb->ioh->cmd_len, SCSI_CDB_MAX_SIZE); + qemu_aio_release(acb); + return NULL; + } + acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s", -- 1.8.3.1