Skip to content

Commit 79593c0

Browse files
dwmw2bonzini
authored andcommitted
KVM: avoid double put_page with gfn-to-pfn cache
If the cache's user host virtual address becomes invalid, there is still a path from kvm_gfn_to_pfn_cache_refresh() where __release_gpc() could release the pfn but the gpc->pfn field has not been overwritten with an error value. If this happens, kvm_gfn_to_pfn_cache_unmap will call put_page again on the same page. Cc: stable@vger.kernel.org Fixes: 982ed0d ("KVM: Reinstate gfn_to_pfn_cache with invalidation support") Signed-off-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent f47e5bb commit 79593c0

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

virt/kvm/pfncache.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ int kvm_gfn_to_pfn_cache_refresh(struct kvm *kvm, struct gfn_to_pfn_cache *gpc,
191191
gpc->uhva = gfn_to_hva_memslot(gpc->memslot, gfn);
192192

193193
if (kvm_is_error_hva(gpc->uhva)) {
194+
gpc->pfn = KVM_PFN_ERR_FAULT;
194195
ret = -EFAULT;
195196
goto out;
196197
}

0 commit comments

Comments
 (0)