Skip to content

Commit 7ec37d1

Browse files
vittyvkbonzini
authored andcommitted
KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq
When KVM_CAP_HYPERV_SYNIC{,2} is activated, KVM already checks for irqchip_in_kernel() so normally SynIC irqs should never be set. It is, however, possible for a misbehaving VMM to write to SYNIC/STIMER MSRs causing erroneous behavior. The immediate issue being fixed is that kvm_irq_delivery_to_apic() (kvm_irq_delivery_to_apic_fast()) crashes when called with 'irq.shorthand = APIC_DEST_SELF' and 'src == NULL'. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Message-Id: <20220325132140.25650-2-vkuznets@redhat.com> Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent cde363a commit 7ec37d1

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

arch/x86/kvm/hyperv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ static int synic_set_irq(struct kvm_vcpu_hv_synic *synic, u32 sint)
449449
struct kvm_lapic_irq irq;
450450
int ret, vector;
451451

452+
if (KVM_BUG_ON(!lapic_in_kernel(vcpu), vcpu->kvm))
453+
return -EINVAL;
454+
452455
if (sint >= ARRAY_SIZE(synic->sint))
453456
return -EINVAL;
454457

0 commit comments

Comments
 (0)