Re: [PATCH 08/10] KVM: ARM: VGIC: Fix the parameter check when inject irq to VM.

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

 



On 17/11/14 09:27, wanghaibin wrote:
> Maybe inject irq action is not only from userspace(like arch_timer or
> another in-kernel device in future). So, it maybe better that guarantee
> the parameter valid before inject irq action.

First, we don't defend ourselves from other in-kernel callers. If they
wrong, we fix them.

> Signed-off-by: wanghaibin <wanghaibin.wang@xxxxxxxxxx>
> ---
>  virt/kvm/arm/vgic.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
> index 12026e6..52f3bfa 100644
> --- a/virt/kvm/arm/vgic.c
> +++ b/virt/kvm/arm/vgic.c
> @@ -1621,10 +1621,20 @@ static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid,
>  {
>  	struct vgic_dist *dist = &kvm->arch.vgic;
>  	struct kvm_vcpu *vcpu;
> +	int nrcpus = atomic_read(&kvm->online_vcpus);
>  	int edge_triggered, level_triggered;
>  	int enabled;
>  	bool ret = true;
>  
> +	if ((cpuid >= nrcpus) || (irq_num >= dist->nr_irqs))
> +		return false;
> +
> +	if (irq_num < VGIC_NR_SGIS)
> +		return false;
> +
> +	if ((irq_num >= VGIC_NR_PRIVATE_IRQS) && (cpuid != 0))
> +		return false;
> +
>  	spin_lock(&dist->lock);
>  
>  	vcpu = kvm_get_vcpu(kvm, cpuid);
> 

The only check that could be useful is the one against dist->nr_irqs.
The rest of it is completely useless.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm




[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux