KVM: Don't accept obviously wrong gsi values via KVM_IRQFD
authorJan H. Schönherr <jschoenh@amazon.de>
Thu, 7 Sep 2017 18:02:48 +0000 (19:02 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 15 Sep 2017 14:55:28 +0000 (16:55 +0200)
We cannot add routes for gsi values >= KVM_MAX_IRQ_ROUTES -- see
kvm_set_irq_routing(). Hence, there is no sense in accepting them
via KVM_IRQFD. Prevent them from entering the system in the first
place.

Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/eventfd.c

index f2ac53ab82438f0b473ecd8ed91b1e2548af7ca2..c608ab495282ddb63ace657ce0a6deeea18a2240 100644 (file)
@@ -565,6 +565,8 @@ kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args)
 {
        if (args->flags & ~(KVM_IRQFD_FLAG_DEASSIGN | KVM_IRQFD_FLAG_RESAMPLE))
                return -EINVAL;
+       if (args->gsi >= KVM_MAX_IRQ_ROUTES)
+               return -EINVAL;
 
        if (args->flags & KVM_IRQFD_FLAG_DEASSIGN)
                return kvm_irqfd_deassign(kvm, args);