]> git.baikalelectronics.ru Git - kernel.git/commit
kvm: x86: fix emulator buffer overflow (CVE-2014-0049)
authorAndrew Honig <ahonig@google.com>
Thu, 27 Feb 2014 18:35:14 +0000 (19:35 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 27 Feb 2014 18:35:22 +0000 (19:35 +0100)
commita8815f3206d56a9ab952dfab2e4790d4a07f454b
tree3478565fdecc5064fcc1521f7050f4d3fadb86c1
parent6f4dbc5f13ebc15617a7675650b5c813e5a4db7f
kvm: x86: fix emulator buffer overflow (CVE-2014-0049)

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 destroyed 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.

Fixes: e43aae9b4b0053c733a96ee02ba8d19ee8328ddf
Signed-off-by: Andrew Honig <ahonig@google.com>
Cc: stable@vger.kernel.org (3.5+)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c