From: Christian Borntraeger Date: Thu, 21 Dec 2017 08:18:22 +0000 (+0100) Subject: KVM: s390: prevent buffer overrun on memory hotplug during migration X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=77bbeea7811f0857952d3f096438ce2e1bb16f1a;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git KVM: s390: prevent buffer overrun on memory hotplug during migration commit c2cf265d860882b51a200e4a7553c17827f2b730 upstream. We must not go beyond the pre-allocated buffer. This can happen when a new memory slot is added during migration. Reported-by: David Hildenbrand Signed-off-by: Christian Borntraeger Fixes: 190df4a212a7 (KVM: s390: CMMA tracking, ESSA emulation, migration mode) Reviewed-by: Cornelia Huck Reviewed-by: David Hildenbrand Signed-off-by: Greg Kroah-Hartman --- diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c index 5b25287f449b..7bd3a59232f0 100644 --- a/arch/s390/kvm/priv.c +++ b/arch/s390/kvm/priv.c @@ -1009,7 +1009,7 @@ static inline int do_essa(struct kvm_vcpu *vcpu, const int orc) cbrlo[entries] = gfn << PAGE_SHIFT; } - if (orc) { + if (orc && gfn < ms->bitmap_size) { /* increment only if we are really flipping the bit to 1 */ if (!test_and_set_bit(gfn, ms->pgste_bitmap)) atomic64_inc(&ms->dirty_pages);