kvm: don't take vcpu mutex for obviously invalid vcpu ioctls
[pandora-kernel.git] / virt / kvm / kvm_main.c
index d83aa5e..8b0617a 100644 (file)
@@ -52,6 +52,7 @@
 
 #include <asm/processor.h>
 #include <asm/io.h>
+#include <asm/ioctl.h>
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
 
@@ -1766,6 +1767,9 @@ static long kvm_vcpu_ioctl(struct file *filp,
        if (vcpu->kvm->mm != current->mm)
                return -EIO;
 
+       if (unlikely(_IOC_TYPE(ioctl) != KVMIO))
+               return -EINVAL;
+
 #if defined(CONFIG_S390) || defined(CONFIG_PPC)
        /*
         * Special cases: vcpu ioctls that are asynchronous to vcpu execution,