|
|
619821 |
From 74db251c34369bd32148864b3abea6d6586270dc Mon Sep 17 00:00:00 2001
|
|
|
4f5da8 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
4f5da8 |
Date: Fri, 10 Feb 2017 08:30:15 +0100
|
|
|
4f5da8 |
Subject: [PATCH 3/3] cirrus: add blit_is_unsafe call to
|
|
|
4f5da8 |
cirrus_bitblt_cputovideo
|
|
|
4f5da8 |
|
|
|
4f5da8 |
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
4f5da8 |
Message-id: <1486715415-3462-4-git-send-email-kraxel@redhat.com>
|
|
|
4f5da8 |
Patchwork-id: 73773
|
|
|
4f5da8 |
O-Subject: [virt-devel] [EMBARGOED RHEL-7.4 qemu-kvm PATCH 3/3] cirrus: add blit_is_unsafe call to cirrus_bitblt_cputovideo
|
|
|
619821 |
Bugzilla: 1420492
|
|
|
4f5da8 |
CVE: CVE-2017-2620/20170221
|
|
|
4f5da8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4f5da8 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
4f5da8 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
4f5da8 |
|
|
|
4f5da8 |
CIRRUS_BLTMODE_MEMSYSSRC blits do NOT check blit destination
|
|
|
4f5da8 |
and blit width, at all. Oops. Fix it.
|
|
|
4f5da8 |
|
|
|
4f5da8 |
Security impact: high.
|
|
|
4f5da8 |
|
|
|
4f5da8 |
The missing blit destination check allows to write to host memory.
|
|
|
4f5da8 |
Basically same as CVE-2014-8106 for the other blit variants.
|
|
|
4f5da8 |
|
|
|
4f5da8 |
The missing blit width check allows to overflow cirrus_bltbuf,
|
|
|
4f5da8 |
with the attractive target cirrus_srcptr (current cirrus_bltbuf write
|
|
|
4f5da8 |
position) being located right after cirrus_bltbuf in CirrusVGAState.
|
|
|
4f5da8 |
|
|
|
4f5da8 |
Due to cirrus emulation writing cirrus_bltbuf bytewise the attacker
|
|
|
4f5da8 |
hasn't full control over cirrus_srcptr though, only one byte can be
|
|
|
4f5da8 |
changed. Once the first byte has been modified further writes land
|
|
|
4f5da8 |
elsewhere.
|
|
|
4f5da8 |
|
|
|
4f5da8 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
4f5da8 |
|
|
|
4f5da8 |
Upstream: TBD (embargoed until Feb 21st)
|
|
|
4f5da8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
4f5da8 |
---
|
|
|
4f5da8 |
hw/display/cirrus_vga.c | 8 ++++++++
|
|
|
4f5da8 |
1 file changed, 8 insertions(+)
|
|
|
4f5da8 |
|
|
|
4f5da8 |
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
|
|
|
4f5da8 |
index 9a9501f..1b972db 100644
|
|
|
4f5da8 |
--- a/hw/display/cirrus_vga.c
|
|
|
4f5da8 |
+++ b/hw/display/cirrus_vga.c
|
|
|
4f5da8 |
@@ -894,6 +894,10 @@ static int cirrus_bitblt_cputovideo(CirrusVGAState * s)
|
|
|
4f5da8 |
{
|
|
|
4f5da8 |
int w;
|
|
|
4f5da8 |
|
|
|
4f5da8 |
+ if (blit_is_unsafe(s, true)) {
|
|
|
4f5da8 |
+ return 0;
|
|
|
4f5da8 |
+ }
|
|
|
4f5da8 |
+
|
|
|
4f5da8 |
s->cirrus_blt_mode &= ~CIRRUS_BLTMODE_MEMSYSSRC;
|
|
|
4f5da8 |
s->cirrus_srcptr = &s->cirrus_bltbuf[0];
|
|
|
4f5da8 |
s->cirrus_srcptr_end = &s->cirrus_bltbuf[0];
|
|
|
4f5da8 |
@@ -919,6 +923,10 @@ static int cirrus_bitblt_cputovideo(CirrusVGAState * s)
|
|
|
4f5da8 |
}
|
|
|
4f5da8 |
s->cirrus_srccounter = s->cirrus_blt_srcpitch * s->cirrus_blt_height;
|
|
|
4f5da8 |
}
|
|
|
4f5da8 |
+
|
|
|
4f5da8 |
+ /* the blit_is_unsafe call above should catch this */
|
|
|
4f5da8 |
+ assert(s->cirrus_blt_srcpitch <= CIRRUS_BLTBUFSIZE);
|
|
|
4f5da8 |
+
|
|
|
4f5da8 |
s->cirrus_srcptr = s->cirrus_bltbuf;
|
|
|
4f5da8 |
s->cirrus_srcptr_end = s->cirrus_bltbuf + s->cirrus_blt_srcpitch;
|
|
|
4f5da8 |
cirrus_update_memory_access(s);
|
|
|
4f5da8 |
--
|
|
|
4f5da8 |
1.8.3.1
|
|
|
4f5da8 |
|