Bug 1062368 (CVE-2014-0049)

Summary: CVE-2014-0049 kernel: kvm: mmio_fragments out-of-the-bounds access
Product: [Other] Security Response Reporter: Petr Matousek <pmatouse>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED NOTABUG QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: agordeev, anton, aquini, dhoward, drjones, fhrbata, kernel-mgr, lwang, npajkovs, pbonzini, pholasek, security-response-team
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: impact=important,public=20140303,reported=20140205,source=google,cvss2=6.5/AV:A/AC:H/Au:S/C:C/I:C/A:C,rhel-5/kvm=notaffected,rhel-6/kernel=notaffected,mrg-2/realtime-kernel=notaffected,rhel-7/kernel=notaffected,fedora-all/kernel=affected
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-02-06 18:13:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On: 1071836, 1071837    
Bug Blocks: 1062369    

Description Petr Matousek 2014-02-06 18:09:54 UTC
The problem occurs when the guest performs a pusha with the stack address
pointing to an mmio address (or an invalid guest physical address) to
start with, but then extending into an ordinary guest physical address.
When doing repeated emulated pushes emulator_read_write sets mmio_needed
to 1 on the first one.  On a later push when the stack points to regular
memory, mmio_nr_fragments is set to 0, but mmio_is_needed is not set
to 0.

As a result, KVM exits to userspace, and then returns to
complete_emulated_mmio.  In complete_emulated_mmio
vcpu->mmio_cur_fragment is incremented.  The termination condition of
vcpu->mmio_cur_fragment == vcpu->mmio_nr_fragments is never achieved.
The code bounces back and fourth to userspace incrementing
mmio_cur_fragment past it's buffer.  If the guest does nothing else it
eventually leads to a a crash on a memcpy from invalid memory address.

However if a guest code can cause the vm to be destoryed in another
vcpu with excellent timing, then kvm_clear_async_pf_completion_queue
can be used by the guest to control the data that's pointed to by the
call to cancel_work_item, which can be used to gain execution.

Introduced by:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=f78146b0f

Acknowledgements:

Red Hat would like to thank Lars Bull of Google for reporting this issue.

Comment 1 Petr Matousek 2014-02-06 18:13:55 UTC
Statement:

Not vulnerable.

This issue did not affect the versions of kvm package as shipped with Red
Hat Enterprise Linux 5 as they did not backport the upstream kvm commit
that introduced this issue.

This issue did not affect the versions of Linux kernel as shipped Red Hat
Enterprise Linux 6 as they did not backport the upstream kvm commit that
introduced this issue.

This issue did not affect the versions of Linux kernel as shipped Red Hat
Enterprise MRG as they did not provide support for the KVM subsystem.

Comment 4 Petr Matousek 2014-03-03 09:34:07 UTC
Created kernel tracking bugs for this issue:

Affects: fedora-all [bug 1071837]

Comment 5 Fedora Update System 2014-03-06 08:09:42 UTC
kernel-3.13.5-202.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 6 Fedora Update System 2014-03-09 04:38:20 UTC
kernel-3.13.5-103.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.