Skip to content

Commit 507e72f

Browse files
committed
Merge tag 'kvm-x86-generic-6.9' of https://github.com/kvm-x86/linux into HEAD
KVM common MMU changes for 6.9: - Harden KVM against underflowing the active mmu_notifier invalidation count, so that "bad" invalidations (usually due to bugs elsehwere in the kernel) are detected earlier and are less likely to hang the kernel. - Fix a benign bug in __kvm_mmu_topup_memory_cache() where the object size and number of objects parameters to kvmalloc_array() were swapped.
2 parents a81d95a + ea3689d commit 507e72f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

virt/kvm/kvm_main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ int __kvm_mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int capacity,
421421
if (WARN_ON_ONCE(!capacity))
422422
return -EIO;
423423

424-
mc->objects = kvmalloc_array(sizeof(void *), capacity, gfp);
424+
mc->objects = kvmalloc_array(capacity, sizeof(void *), gfp);
425425
if (!mc->objects)
426426
return -ENOMEM;
427427

@@ -890,7 +890,9 @@ static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn,
890890

891891
/* Pairs with the increment in range_start(). */
892892
spin_lock(&kvm->mn_invalidate_lock);
893-
wake = (--kvm->mn_active_invalidate_count == 0);
893+
if (!WARN_ON_ONCE(!kvm->mn_active_invalidate_count))
894+
--kvm->mn_active_invalidate_count;
895+
wake = !kvm->mn_active_invalidate_count;
894896
spin_unlock(&kvm->mn_invalidate_lock);
895897

896898
/*

0 commit comments

Comments
 (0)