Skip to content

Commit a476cad

Browse files
Dan Carpentersean-jc
authored andcommitted
KVM: x86: Check that the high 32bits are clear in kvm_arch_vcpu_ioctl_run()
The "kvm_run->kvm_valid_regs" and "kvm_run->kvm_dirty_regs" variables are u64 type. We are only using the lowest 3 bits but we want to ensure that the users are not passing invalid bits so that we can use the remaining bits in the future. However "sync_valid_fields" and kvm_sync_valid_fields() are u32 type so the check only ensures that the lower 32 bits are clear. Fix this by changing the types to u64. Fixes: 74c1807 ("KVM: x86: block KVM_CAP_SYNC_REGS if guest state is protected") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/r/ec25aad1-113e-4c6e-8941-43d432251398@stanley.mountain Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent a2620f8 commit a476cad

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/kvm/x86.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4597,7 +4597,7 @@ static bool kvm_is_vm_type_supported(unsigned long type)
45974597
return type < 32 && (kvm_caps.supported_vm_types & BIT(type));
45984598
}
45994599

4600-
static inline u32 kvm_sync_valid_fields(struct kvm *kvm)
4600+
static inline u64 kvm_sync_valid_fields(struct kvm *kvm)
46014601
{
46024602
return kvm && kvm->arch.has_protected_state ? 0 : KVM_SYNC_X86_VALID_FIELDS;
46034603
}
@@ -11493,7 +11493,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
1149311493
{
1149411494
struct kvm_queued_exception *ex = &vcpu->arch.exception;
1149511495
struct kvm_run *kvm_run = vcpu->run;
11496-
u32 sync_valid_fields;
11496+
u64 sync_valid_fields;
1149711497
int r;
1149811498

1149911499
r = kvm_mmu_post_init_vm(vcpu->kvm);

0 commit comments

Comments
 (0)