cf91b1d
From: Gerd Hoffmann <kraxel@redhat.com>
cf91b1d
Date: Mon, 30 May 2016 09:09:19 +0200
cf91b1d
Subject: [PATCH] vmsvga: add more fifo checks
cf91b1d
MIME-Version: 1.0
cf91b1d
Content-Type: text/plain; charset=UTF-8
cf91b1d
Content-Transfer-Encoding: 8bit
cf91b1d
cf91b1d
Make sure all fifo ptrs are within range.
cf91b1d
cf91b1d
Fixes: CVE-2016-4454
cf91b1d
Cc: qemu-stable@nongnu.org
cf91b1d
Cc: P J P <ppandit@redhat.com>
cf91b1d
Reported-by: 李强 <liqiang6-s@360.cn>
cf91b1d
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
cf91b1d
Message-id: 1464592161-18348-3-git-send-email-kraxel@redhat.com
cf91b1d
(cherry picked from commit c2e3c54d3960bc53bfa3a5ce7ea7a050b9be267e)
cf91b1d
---
cf91b1d
 hw/display/vmware_vga.c | 5 ++++-
cf91b1d
 1 file changed, 4 insertions(+), 1 deletion(-)
cf91b1d
cf91b1d
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
cf91b1d
index 63a7c05..a26e62e 100644
cf91b1d
--- a/hw/display/vmware_vga.c
cf91b1d
+++ b/hw/display/vmware_vga.c
cf91b1d
@@ -563,7 +563,10 @@ static inline int vmsvga_fifo_length(struct vmsvga_state_s *s)
cf91b1d
     if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo) {
cf91b1d
         return 0;
cf91b1d
     }
cf91b1d
-    if (CMD(max) > SVGA_FIFO_SIZE) {
cf91b1d
+    if (CMD(max) > SVGA_FIFO_SIZE ||
cf91b1d
+        CMD(min) >= SVGA_FIFO_SIZE ||
cf91b1d
+        CMD(stop) >= SVGA_FIFO_SIZE ||
cf91b1d
+        CMD(next_cmd) >= SVGA_FIFO_SIZE) {
cf91b1d
         return 0;
cf91b1d
     }
cf91b1d
     if (CMD(max) < CMD(min) + 10 * 1024) {