Re: [PATCH 1/2] KVM: Reject overly excessive IDs in KVM_CREATE_VCPU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06.06.24 20:11, Mathias Krause wrote:
> +   /*
> +    * KVM tracks vCPU IDs as 'int', be kind to userspace and reject
> +    * too-large values instead of silently truncating.
> +    *
> +    * Also ensure we're not breaking this assumption by accidentally
> +    * pushing KVM_MAX_VCPU_IDS above INT_MAX.
> +    */
> +   BUILD_BUG_ON(KVM_MAX_VCPU_IDS > INT_MAX);

And yes, I'd rather like to write the above as something like below to
account for type changes:

    BUILD_BUG_ON(KVM_MAX_VCPU_IDS > typeof(vcpu->vcpu_id)::max());

But, unfortunately, C is not there yet. One could try to implement
something based on _Generic() but, meh..

>     if (id >= KVM_MAX_VCPU_IDS)
>         return -EINVAL;
> 




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux