cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-iscsi-Don-t-blindly-use-designator-length-in-respons.patch

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