Patch "KVM: Assert that mmu_invalidate_in_progress *never* goes negative" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    KVM: Assert that mmu_invalidate_in_progress *never* goes negative

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kvm-assert-that-mmu_invalidate_in_progress-never-goe.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 5566397d2a56c5c8dacbcd391db95a84994fac00
Author: Sean Christopherson <seanjc@xxxxxxxxxx>
Date:   Fri Oct 27 11:21:44 2023 -0700

    KVM: Assert that mmu_invalidate_in_progress *never* goes negative
    
    [ Upstream commit c0db19232c1ed6bd7fcb825c28b014c52732c19e ]
    
    Move the assertion on the in-progress invalidation count from the primary
    MMU's notifier path to KVM's common notification path, i.e. assert that
    the count doesn't go negative even when the invalidation is coming from
    KVM itself.
    
    Opportunistically convert the assertion to a KVM_BUG_ON(), i.e. kill only
    the affected VM, not the entire kernel.  A corrupted count is fatal to the
    VM, e.g. the non-zero (negative) count will cause mmu_invalidate_retry()
    to block any and all attempts to install new mappings.  But it's far from
    guaranteed that an end() without a start() is fatal or even problematic to
    anything other than the target VM, e.g. the underlying bug could simply be
    a duplicate call to end().  And it's much more likely that a missed
    invalidation, i.e. a potential use-after-free, would manifest as no
    notification whatsoever, not an end() without a start().
    
    Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
    Reviewed-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
    Reviewed-by: Fuad Tabba <tabba@xxxxxxxxxx>
    Tested-by: Fuad Tabba <tabba@xxxxxxxxxx>
    Message-Id: <20231027182217.3615211-3-seanjc@xxxxxxxxxx>
    Reviewed-by: Kai Huang <kai.huang@xxxxxxxxx>
    Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
    Stable-dep-of: c3f3edf73a8f ("KVM: Stop processing *all* memslots when "null" mmu_notifier handler is found")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 0524933856d42..5a97e6c7d9c20 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -833,6 +833,7 @@ void kvm_mmu_invalidate_end(struct kvm *kvm, unsigned long start,
 	 * in conjunction with the smp_rmb in mmu_invalidate_retry().
 	 */
 	kvm->mmu_invalidate_in_progress--;
+	KVM_BUG_ON(kvm->mmu_invalidate_in_progress < 0, kvm);
 }
 
 static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn,
@@ -863,8 +864,6 @@ static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn,
 	 */
 	if (wake)
 		rcuwait_wake_up(&kvm->mn_memslots_update_rcuwait);
-
-	BUG_ON(kvm->mmu_invalidate_in_progress < 0);
 }
 
 static int kvm_mmu_notifier_clear_flush_young(struct mmu_notifier *mn,




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux