From 5458b50b5291390ce0af2872a1baa51cc58e8f08 Mon Sep 17 00:00:00 2001 From: Yanfei Xu Date: Sun, 31 May 2026 21:53:26 +0800 Subject: [PATCH] KVM: PPC: Validate irqchip index in MPIC routing Sashiko reported that the irqchip index is not validated for PowerPC. Add validation and reject out-of-range irqchip indexes to avoid indexing past the routing table's chip array. Fixes: de9ba2f36368 ("KVM: PPC: Support irq routing and irqfd for in-kernel MPIC") Reported-by: Sashiko Closes: https://lore.kernel.org/kvm/20260525051714.485D51F000E9@smtp.kernel.org/ Reviewed-by: Harsh Prateek Bora Signed-off-by: Yanfei Xu Signed-off-by: Madhavan Srinivasan --- arch/powerpc/kvm/mpic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/mpic.c b/arch/powerpc/kvm/mpic.c index 3070f36d9fb8..fb5f9e65e02e 100644 --- a/arch/powerpc/kvm/mpic.c +++ b/arch/powerpc/kvm/mpic.c @@ -1833,7 +1833,8 @@ int kvm_set_routing_entry(struct kvm *kvm, e->set = mpic_set_irq; e->irqchip.irqchip = ue->u.irqchip.irqchip; e->irqchip.pin = ue->u.irqchip.pin; - if (e->irqchip.pin >= KVM_IRQCHIP_NUM_PINS) + if (e->irqchip.pin >= KVM_IRQCHIP_NUM_PINS || + e->irqchip.irqchip >= KVM_NR_IRQCHIPS) goto out; break; case KVM_IRQ_ROUTING_MSI: