Bug 1809955 (CVE-2020-11869)

Summary: CVE-2020-11869 qemu: integer overflow in ati_2d_blt() in hw/display/ati-2d.c could lead to DoS
Product: [Other] Security Response Reporter: Mauro Matteo Cascella <mcascell>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED WONTFIX QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: unspecifiedCC: ailan, amit, areis, berrange, cfergeau, dbecker, drjones, dwmw2, imammedo, itamar, jen, jferlan, jforbes, jjoyce, jmaloy, jschluet, kbasil, knoel, lhh, lkundrak, lpeer, m.a.young, mburns, mkenneth, mrezanin, mst, pbonzini, ribarry, rjones, robinlee.sysu, sclewis, security-response-team, slinaber, virt-maint, virt-maint, vkuznets, xen-maint
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: qemu 5.0.0 Doc Type: If docs needed, set a value
Doc Text:
An integer overflow flaw was found in QEMU in the way it implemented the ATI VGA emulation. This flaw occurs in the ati_2d_blt() routine while handling MMIO write operations through ati_mm_write() callback. A malicious guest could abuse this flaw to crash the QEMU process, resulting in a denial of service.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-24 16:31:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1819709, 1847474, 1910687    
Bug Blocks: 1786592    

Description Mauro Matteo Cascella 2020-03-04 10:02:05 UTC
Function ati_2d_blt() in hw/display/ati-2d.c is affected by an integer overflow
vulnerability leading to potential out-of-bounds read/write operations. 

Specifically, variables `s->regs.dst_x` and `s->regs.dst_y` are set to less than
0x3fff in function ati_mm_write() in ati.c. However, it turns out they can
infinitely increase the size to exceed 0x3fff in the switch case ROP3_SRCCOPY
in function ati_2d_blt(): 

1) when looping, first set `dst_stride` to 0 to pass the check 
   `dst_bits + dst_x + (dst_y + s-> regs.dst_height) * dst_stride> = end`

2) after `dst_x` and `dst_y` assume a large value, `dst_stride` can be set

3) expression `dst_x + (dst_y + s-> regs.dst_height) * dst_stride` can be set
   to a large value (like 0xffffffff). When using a 32-bit operating system,
   the pointer plus 0xffffffff can pass the check.

This will cause wrong memory access leading to out-of-bounds read/write in
function pixman_blt().

Upstream fix:
https://git.qemu.org/?p=qemu.git;a=commit;h=ac2071c3791b67fc7af78b8ceb320c01ca1b5df7

Comment 2 Joshua Padman 2020-03-16 01:13:19 UTC
Statement:

This flaw did not affect the following versions of QEMU as they did not include support for ATI VGA emulation:
* `qemu-kvm-ma` as shipped with Red Hat Enterprise Linux 7.
* `qemu-kvm-rhev` as shipped with Red Hat Virtualization and Red Hat OpenStack.
* `qemu-kvm` as shipped with Red Hat Enterprise Linux 6, 7 and 8.

ATI VGA emulation feature was introduced in QEMU upstream version v4.0.0.

Comment 4 Mauro Matteo Cascella 2020-04-01 11:18:00 UTC
Acknowledgments:

Name: Ziming Zhang

Comment 5 Mauro Matteo Cascella 2020-04-14 09:09:11 UTC
Upstream fix:
https://git.qemu.org/?p=qemu.git;a=commit;h=ac2071c3791b67fc7af78b8ceb320c01ca1b5df7

Comment 7 Product Security DevOps Team 2020-04-24 16:31:47 UTC
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s):

https://access.redhat.com/security/cve/cve-2020-11869

Comment 8 Mauro Matteo Cascella 2020-06-16 13:01:06 UTC
Created qemu tracking bugs for this issue:

Affects: fedora-all [bug 1847474]