Skip to contentSkip to conversation

KVM: x86: Zero the IOAPIC scan request dest vCPUs bitmap

PATCH Applied Nitesh Narayan Lal 2 participants 2 messages Nov 20, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: x86: Zero the IOAPIC scan request dest vCPUs bitmap

Not zeroing the bitmap used for identifying the destination vCPUs for an IOAPIC scan request in fixed delivery mode could lead to waking up unwanted vCPUs. This patch zeroes the vCPU bitmap before passing it to kvm_bitmap_or_dest_vcpus(), which is responsible for setting the bitmap with the bits corresponding to the destination vCPUs.

Fixes 7ee30bc132c6("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs")
---
 arch/x86/kvm/ioapic.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kvm/ioapic.c +1 -0
index ce30ef23c86b..9fd2dd89a1c5 100644
@@ -332,6 +332,7 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)
 			irq.delivery_mode = e->fields.delivery_mode << 8;
 			irq.dest_id = e->fields.dest_id;
 			irq.dest_mode = e->fields.dest_mode;
+			bitmap_zero(&vcpu_bitmap, 16);
 			kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq,
 						 &vcpu_bitmap);
 			if (old_dest_mode != e->fields.dest_mode ||
Signature · 1 line
2.18.1
maintainer Applied
#1 lore raw
Quoted 18 lines · Nitesh Narayan Lal

Not zeroing the bitmap used for identifying the destination vCPUs for an IOAPIC scan request in fixed delivery mode could lead to waking up unwanted vCPUs. This patch zeroes the vCPU bitmap before passing it to kvm_bitmap_or_dest_vcpus(), which is responsible for setting the bitmap with the bits corresponding to the destination vCPUs.

Fixes 7ee30bc132c6("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs")
---
 arch/x86/kvm/ioapic.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kvm/ioapic.c +0 -0
index ce30ef23c86b..9fd2dd89a1c5 100644

arch/x86/kvm/ioapic.c static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) · line 338

Quoted 7 lines
arch/x86/kvm/ioapic.c +1 -0
@@ -332,6 +332,7 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)
 			irq.delivery_mode = e->fields.delivery_mode << 8;
 			irq.dest_id = e->fields.dest_id;
 			irq.dest_mode = e->fields.dest_mode;
+			bitmap_zero(&vcpu_bitmap, 16);
 			kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq,
 						 &vcpu_bitmap);
 			if (old_dest_mode != e->fields.dest_mode ||

Queued, thanks.

Paolo