|
|
ae23c9 |
From bc4b0e1c80d9f9e2acf44ef99b7771f96be90791 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ae23c9 |
Date: Thu, 20 Dec 2018 12:31:01 +0000
|
|
|
ae23c9 |
Subject: [PATCH 6/8] scsi-generic: avoid out-of-bounds access to VPD page list
|
|
|
ae23c9 |
MIME-Version: 1.0
|
|
|
ae23c9 |
Content-Type: text/plain; charset=UTF-8
|
|
|
ae23c9 |
Content-Transfer-Encoding: 8bit
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ae23c9 |
Message-id: <20181220123103.29579-7-pbonzini@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 83715
|
|
|
ae23c9 |
O-Subject: [PATCH 6/8] scsi-generic: avoid out-of-bounds access to VPD page list
|
|
|
ae23c9 |
Bugzilla: 1639957
|
|
|
ae23c9 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
A device can report an excessive number of VPD pages when asked for a
|
|
|
ae23c9 |
list; this can cause an out-of-bounds access to buf in
|
|
|
ae23c9 |
scsi_generic_set_vpd_bl_emulation. It should not happen, but
|
|
|
ae23c9 |
it is technically not incorrect so handle it: do not check any byte
|
|
|
ae23c9 |
past the allocation length that was sent to the INQUIRY command.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Reported-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit 57dbb58d800f62b9e56d946660dba4e8dbd20204)
|
|
|
ae23c9 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
hw/scsi/scsi-generic.c | 2 +-
|
|
|
ae23c9 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
|
|
|
ae23c9 |
index 98c6a34..6d6db69 100644
|
|
|
ae23c9 |
--- a/hw/scsi/scsi-generic.c
|
|
|
ae23c9 |
+++ b/hw/scsi/scsi-generic.c
|
|
|
ae23c9 |
@@ -539,7 +539,7 @@ static void scsi_generic_set_vpd_bl_emulation(SCSIDevice *s)
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
page_len = buf[3];
|
|
|
ae23c9 |
- for (i = 4; i < page_len + 4; i++) {
|
|
|
ae23c9 |
+ for (i = 4; i < MIN(sizeof(buf), page_len + 4); i++) {
|
|
|
ae23c9 |
if (buf[i] == 0xb0) {
|
|
|
ae23c9 |
s->needs_vpd_bl_emulation = false;
|
|
|
ae23c9 |
return;
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|