]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: MMU: always terminate page walks at level 1
authorLadi Prosek <lprosek@redhat.com>
Thu, 5 Oct 2017 09:10:23 +0000 (11:10 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 10 Oct 2017 13:31:28 +0000 (15:31 +0200)
commit0f961d71f0905299215508fb28952f9c223408d5
tree4d820edec657b7fa4c79e1877b87ff86d5c3aed9
parentcc2e838a11eafb0696ceec966045cc8aff6c692e
KVM: MMU: always terminate page walks at level 1

is_last_gpte() is not equivalent to the pseudo-code given in commit
35b3b783018df ("KVM: MMU: simplify last_pte_bitmap") because an incorrect
value of last_nonleaf_level may override the result even if level == 1.

It is critical for is_last_gpte() to return true on level == 1 to
terminate page walks. Otherwise memory corruption may occur as level
is used as an index to various data structures throughout the page
walking code.  Even though the actual bug would be wherever the MMU is
initialized (as in the previous patch), be defensive and ensure here
that is_last_gpte() returns the correct value.

This patch is also enough to fix CVE-2017-12188.

Fixes: 35b3b783018dfc80f2988f66f64a2ced7c0b68c9
Cc: stable@vger.kernel.org
Cc: Andy Honig <ahonig@google.com>
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
[Panic if walk_addr_generic gets an incorrect level; this is a serious
 bug and it's not worth a WARN_ON where the recovery path might hide
 further exploitable issues; suggested by Andrew Honig. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu.c
arch/x86/kvm/paging_tmpl.h