]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: do not allow mapping valid but non-reference-counted pages
authorNicholas Piggin <npiggin@gmail.com>
Thu, 24 Jun 2021 12:29:04 +0000 (08:29 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 24 Jun 2021 15:55:11 +0000 (11:55 -0400)
commite42efe4f4ca5c9b62c4a115da5348922cc43ca4e
tree2f291bec641f75e1f350177da6179e8316699d71
parent3c95b97c53e2a4fb089608334750e9e7bf607f49
KVM: do not allow mapping valid but non-reference-counted pages

It's possible to create a region which maps valid but non-refcounted
pages (e.g., tail pages of non-compound higher order allocations). These
host pages can then be returned by gfn_to_page, gfn_to_pfn, etc., family
of APIs, which take a reference to the page, which takes it from 0 to 1.
When the reference is dropped, this will free the page incorrectly.

Fix this by only taking a reference on valid pages if it was non-zero,
which indicates it is participating in normal refcounting (and can be
released with put_page).

This addresses CVE-2021-22543.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/kvm_main.c