diff options
author | Marc Zyngier <maz@kernel.org> | 2024-08-08 11:15:46 +0200 |
---|---|---|
committer | Oliver Upton <oliver.upton@linux.dev> | 2024-08-08 18:58:22 +0200 |
commit | 9eb18136af9fe4dd688724070f2bfba271bd1542 (patch) | |
tree | e7d8020f2ddc2e13f7ced8b8c7cd686121bf8f57 /arch/arm64/kvm/vgic | |
parent | KVM: selftests: arm64: Correct feature test for S1PIE in get-reg-list (diff) | |
download | linux-9eb18136af9fe4dd688724070f2bfba271bd1542.tar.xz linux-9eb18136af9fe4dd688724070f2bfba271bd1542.zip |
KVM: arm64: vgic: Hold config_lock while tearing down a CPU interface
Tearing down a vcpu CPU interface involves freeing the private interrupt
array. If we don't hold the lock, we may race against another thread
trying to configure it. Yeah, fuzzers do wonderful things...
Taking the lock early solves this particular problem.
Fixes: 03b3d00a70b5 ("KVM: arm64: vgic: Allocate private interrupts on demand")
Reported-by: Alexander Potapenko <glider@google.com>
Tested-by: Alexander Potapenko <glider@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20240808091546.3262111-1-maz@kernel.org
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Diffstat (limited to 'arch/arm64/kvm/vgic')
-rw-r--r-- | arch/arm64/kvm/vgic/vgic-init.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c index 7f68cf58b978..41feb858ff9a 100644 --- a/arch/arm64/kvm/vgic/vgic-init.c +++ b/arch/arm64/kvm/vgic/vgic-init.c @@ -438,14 +438,13 @@ void kvm_vgic_destroy(struct kvm *kvm) unsigned long i; mutex_lock(&kvm->slots_lock); + mutex_lock(&kvm->arch.config_lock); vgic_debug_destroy(kvm); kvm_for_each_vcpu(i, vcpu, kvm) __kvm_vgic_vcpu_destroy(vcpu); - mutex_lock(&kvm->arch.config_lock); - kvm_vgic_dist_destroy(kvm); mutex_unlock(&kvm->arch.config_lock); |