Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KVM: guest_mem: Prevent overflows in kvm_gmem_invalidate_begin()
Remove WARN_ON_ONCE in kvm_gmem_invalidate_begin(), because when cleaning up a file, kvm_gmem_invalidate_begin() will be called with 0 and -1ul, and will cause a warning as long as the memslot doesn't begin at index 0. Taking max(gmem.index, start) ensures that 0 <= index_start - gmem.index There will be no overflow when adding that difference to base_gfn because xa_for_each_range() will only iterate ranges where gmem.index <= start < gmem.index + slot->npages Hence, 0 <= index_start - gmem.index < gmem.index + slot->npages Since (slot->base_gfn + slot->npages) and (gmem.index + slot->npages) never overflow (checked at memslot creation time), then the calculation of gfn_range.start will not overflow. Similar reasoning for gfn_range.end applies. Signed-off-by: Ackerley Tng <ackerleytng@google.com>
- Loading branch information