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