|
|
357786 |
From cb9d3b91772324bb697a0f3b89ecc181f59629e2 Mon Sep 17 00:00:00 2001
|
|
|
357786 |
From: Fam Zheng <famz@redhat.com>
|
|
|
357786 |
Date: Fri, 29 Jun 2018 06:11:52 +0200
|
|
|
357786 |
Subject: [PATCH 48/57] iscsi: Don't blindly use designator length in response
|
|
|
357786 |
for memcpy
|
|
|
357786 |
|
|
|
357786 |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
357786 |
Message-id: <20180629061153.12687-13-famz@redhat.com>
|
|
|
357786 |
Patchwork-id: 81162
|
|
|
357786 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH v2 12/13] iscsi: Don't blindly use designator length in response for memcpy
|
|
|
357786 |
Bugzilla: 1482537
|
|
|
357786 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
357786 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
357786 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
Per SCSI definition the designator_length we receive from INQUIRY is 8,
|
|
|
357786 |
12 or at most 16, but we should be careful because the remote iscsi
|
|
|
357786 |
target may misbehave, otherwise we could have a buffer overflow.
|
|
|
357786 |
|
|
|
357786 |
Reported-by: Max Reitz <mreitz@redhat.com>
|
|
|
357786 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
357786 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
357786 |
---
|
|
|
357786 |
block/iscsi.c | 2 +-
|
|
|
357786 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/iscsi.c b/block/iscsi.c
|
|
|
357786 |
index fbcd5bb..751884d 100644
|
|
|
357786 |
--- a/block/iscsi.c
|
|
|
357786 |
+++ b/block/iscsi.c
|
|
|
357786 |
@@ -2226,7 +2226,7 @@ static void iscsi_populate_target_desc(unsigned char *desc, IscsiLun *lun)
|
|
|
357786 |
desc[5] = (dd->designator_type & 0xF)
|
|
|
357786 |
| ((dd->association & 3) << 4);
|
|
|
357786 |
desc[7] = dd->designator_length;
|
|
|
357786 |
- memcpy(desc + 8, dd->designator, dd->designator_length);
|
|
|
357786 |
+ memcpy(desc + 8, dd->designator, MIN(dd->designator_length, 20));
|
|
|
357786 |
|
|
|
357786 |
desc[28] = 0;
|
|
|
357786 |
desc[29] = (lun->block_size >> 16) & 0xFF;
|
|
|
357786 |
--
|
|
|
357786 |
1.8.3.1
|
|
|
357786 |
|