Skip to content

Commit cf5029d

Browse files
suomilewisbonzini
authored andcommitted
KVM: x86: Protect the unused bits in MSR exiting flags
The flags for KVM_CAP_X86_USER_SPACE_MSR and KVM_X86_SET_MSR_FILTER have no protection for their unused bits. Without protection, future development for these features will be difficult. Add the protection needed to make it possible to extend these features in the future. Signed-off-by: Aaron Lewis <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent dc951e2 commit cf5029d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/x86/kvm/x86.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6029,6 +6029,11 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
60296029
r = 0;
60306030
break;
60316031
case KVM_CAP_X86_USER_SPACE_MSR:
6032+
r = -EINVAL;
6033+
if (cap->args[0] & ~(KVM_MSR_EXIT_REASON_INVAL |
6034+
KVM_MSR_EXIT_REASON_UNKNOWN |
6035+
KVM_MSR_EXIT_REASON_FILTER))
6036+
break;
60326037
kvm->arch.user_space_msr_mask = cap->args[0];
60336038
r = 0;
60346039
break;
@@ -6183,6 +6188,9 @@ static int kvm_vm_ioctl_set_msr_filter(struct kvm *kvm, void __user *argp)
61836188
if (copy_from_user(&filter, user_msr_filter, sizeof(filter)))
61846189
return -EFAULT;
61856190

6191+
if (filter.flags & ~KVM_MSR_FILTER_DEFAULT_DENY)
6192+
return -EINVAL;
6193+
61866194
for (i = 0; i < ARRAY_SIZE(filter.ranges); i++)
61876195
empty &= !filter.ranges[i].nmsrs;
61886196

0 commit comments

Comments
 (0)