Skip to content

Commit 7c305d5

Browse files
minipli-osssean-jc
authored andcommitted
KVM: x86: Limit check IDs for KVM_SET_BOOT_CPU_ID
Do not accept IDs which are definitely invalid by limit checking the passed value against KVM_MAX_VCPU_IDS and 'max_vcpu_ids' if it was already set. This ensures invalid values, especially on 64-bit systems, don't go unnoticed and lead to a valid id by chance when truncated by the final assignment. Fixes: 73880c8 ("KVM: Break dependency between vcpu index in vcpus array and vcpu_id.") Signed-off-by: Mathias Krause <[email protected]> Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Sean Christopherson <[email protected]> Signed-off-by: Sean Christopherson <[email protected]>
1 parent 8b8e57e commit 7c305d5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/x86/kvm/x86.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7228,6 +7228,9 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
72287228
mutex_lock(&kvm->lock);
72297229
if (kvm->created_vcpus)
72307230
r = -EBUSY;
7231+
else if (arg > KVM_MAX_VCPU_IDS ||
7232+
(kvm->arch.max_vcpu_ids && arg > kvm->arch.max_vcpu_ids))
7233+
r = -EINVAL;
72317234
else
72327235
kvm->arch.bsp_vcpu_id = arg;
72337236
mutex_unlock(&kvm->lock);

0 commit comments

Comments
 (0)