Received: from eggs.gnu.org ([2001:4830:134:3::10]:41797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWrk7-0003xx-Ok for qemu-devel@nongnu.org; Mon, 08 Aug 2016 17:05:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWrk4-0005va-IU for qemu-devel@nongnu.org; Mon, 08 Aug 2016 17:05:51 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:19125 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWrk4-0005vO-Cg for qemu-devel@nongnu.org; Mon, 08 Aug 2016 17:05:48 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u78KxnIU105555 for ; Mon, 8 Aug 2016 17:05:48 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 24nbs0rmn3-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 08 Aug 2016 17:05:47 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 8 Aug 2016 15:05:47 -0600 From: Michael Roth Date: Mon, 8 Aug 2016 16:03:57 -0500 In-Reply-To: <1470690267-31454-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1470690267-31454-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Message-Id: <1470690267-31454-27-git-send-email-mdroth@linux.vnet.ibm.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 26/56] vmsvga: move fifo sanity checks to vmsvga_fifo_length List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Gerd Hoffmann , P J P From: Gerd Hoffmann Sanity checks are applied when the fifo is enabled by the guest (SVGA_REG_CONFIG_DONE write). Which doesn't help much if the guest changes the fifo registers afterwards. Move the checks to vmsvga_fifo_length so they are done each time qemu is about to read from the fifo. Fixes: CVE-2016-4454 Cc: qemu-stable@nongnu.org Cc: P J P Reported-by: =E6=9D=8E=E5=BC=BA Signed-off-by: Gerd Hoffmann Message-id: 1464592161-18348-2-git-send-email-kraxel@redhat.com (cherry picked from commit 521360267876d3b6518b328051a2e56bca55bef8) Signed-off-by: Michael Roth --- hw/display/vmware_vga.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index 0c63fa8..63a7c05 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -555,6 +555,21 @@ static inline int vmsvga_fifo_length(struct vmsvga_s= tate_s *s) if (!s->config || !s->enable) { return 0; } + + /* Check range and alignment. */ + if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) { + return 0; + } + if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo) { + return 0; + } + if (CMD(max) > SVGA_FIFO_SIZE) { + return 0; + } + if (CMD(max) < CMD(min) + 10 * 1024) { + return 0; + } + num =3D CMD(next_cmd) - CMD(stop); if (num < 0) { num +=3D CMD(max) - CMD(min); @@ -1005,19 +1020,6 @@ static void vmsvga_value_write(void *opaque, uint3= 2_t address, uint32_t value) case SVGA_REG_CONFIG_DONE: if (value) { s->fifo =3D (uint32_t *) s->fifo_ptr; - /* Check range and alignment. */ - if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) { - break; - } - if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fif= o) { - break; - } - if (CMD(max) > SVGA_FIFO_SIZE) { - break; - } - if (CMD(max) < CMD(min) + 10 * 1024) { - break; - } vga_dirty_log_stop(&s->vga); } s->config =3D !!value; --=20 1.9.1