Skip to content

Commit

Permalink
KVM: Don't accept obviously wrong gsi values via KVM_IRQFD
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
schnhrr authored and bonzini committed Sep 15, 2017
1 parent 51aa68e commit 36ae3c0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions virt/kvm/eventfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 36ae3c0

Please sign in to comment.