* [v2 1/2] KVM: LoongArch: Validate irqchip index in irqfd routing
2026-05-31 13:53 [v2 0/2] KVM: Validate irqchip index in routing entries Yanfei Xu
@ 2026-05-31 13:53 ` Yanfei Xu
2026-06-07 4:41 ` Huacai Chen
2026-05-31 13:53 ` [v2 2/2] KVM: PPC: Validate irqchip index in MPIC routing Yanfei Xu
2026-05-31 14:15 ` [v2 0/2] KVM: Validate irqchip index in routing entries Greg KH
2 siblings, 1 reply; 7+ messages in thread
From: Yanfei Xu @ 2026-05-31 13:53 UTC (permalink / raw)
To: harshpb, zhaotianrui, maobibo, chenhuacai, maddy, npiggin,
sashiko-reviews, seanjc, pbonzini
Cc: kvm, stable, loongarch, linuxppc-dev, caixiangfeng,
fangying.tommy, yanfei.xu, isyanfei.xu, Sashiko
Sashiko reported that the irqchip index is not validated for LoongArch.
Add validation and reject out-of-range irqchip indexes to avoid indexing
past the routing table's chip array.
Fixes: 1928254c5ccb ("LoongArch: KVM: Add irqfd support")
Reported-by: Sashiko <sashiko-bot@kernel•org>
Closes: https://lore.kernel.org/kvm/20260525051714.485D51F000E9@smtp.kernel.org/
Reviewed-by: Bibo Mao <maobibo@loongson•cn>
Signed-off-by: Yanfei Xu <yanfei.xu@bytedance•com>
---
arch/loongarch/kvm/irqfd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/loongarch/kvm/irqfd.c b/arch/loongarch/kvm/irqfd.c
index f4f953b22419..40ed1081c4b6 100644
--- a/arch/loongarch/kvm/irqfd.c
+++ b/arch/loongarch/kvm/irqfd.c
@@ -51,7 +51,8 @@ int kvm_set_routing_entry(struct kvm *kvm,
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)
return -EINVAL;
return 0;
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [v2 1/2] KVM: LoongArch: Validate irqchip index in irqfd routing
2026-05-31 13:53 ` [v2 1/2] KVM: LoongArch: Validate irqchip index in irqfd routing Yanfei Xu
@ 2026-06-07 4:41 ` Huacai Chen
0 siblings, 0 replies; 7+ messages in thread
From: Huacai Chen @ 2026-06-07 4:41 UTC (permalink / raw)
To: Yanfei Xu
Cc: harshpb, zhaotianrui, maobibo, maddy, npiggin, sashiko-reviews,
seanjc, pbonzini, kvm, stable, loongarch, linuxppc-dev,
caixiangfeng, fangying.tommy, isyanfei.xu, Sashiko
Applied, thanks.
Huacai
On Sun, May 31, 2026 at 9:54 PM Yanfei Xu <yanfei.xu@bytedance•com> wrote:
>
> Sashiko reported that the irqchip index is not validated for LoongArch.
> Add validation and reject out-of-range irqchip indexes to avoid indexing
> past the routing table's chip array.
>
> Fixes: 1928254c5ccb ("LoongArch: KVM: Add irqfd support")
> Reported-by: Sashiko <sashiko-bot@kernel•org>
> Closes: https://lore.kernel.org/kvm/20260525051714.485D51F000E9@smtp.kernel.org/
> Reviewed-by: Bibo Mao <maobibo@loongson•cn>
> Signed-off-by: Yanfei Xu <yanfei.xu@bytedance•com>
> ---
> arch/loongarch/kvm/irqfd.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/kvm/irqfd.c b/arch/loongarch/kvm/irqfd.c
> index f4f953b22419..40ed1081c4b6 100644
> --- a/arch/loongarch/kvm/irqfd.c
> +++ b/arch/loongarch/kvm/irqfd.c
> @@ -51,7 +51,8 @@ int kvm_set_routing_entry(struct kvm *kvm,
> 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)
> return -EINVAL;
>
> return 0;
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [v2 2/2] KVM: PPC: Validate irqchip index in MPIC routing
2026-05-31 13:53 [v2 0/2] KVM: Validate irqchip index in routing entries Yanfei Xu
2026-05-31 13:53 ` [v2 1/2] KVM: LoongArch: Validate irqchip index in irqfd routing Yanfei Xu
@ 2026-05-31 13:53 ` Yanfei Xu
2026-05-31 14:15 ` [v2 0/2] KVM: Validate irqchip index in routing entries Greg KH
2 siblings, 0 replies; 7+ messages in thread
From: Yanfei Xu @ 2026-05-31 13:53 UTC (permalink / raw)
To: harshpb, zhaotianrui, maobibo, chenhuacai, maddy, npiggin,
sashiko-reviews, seanjc, pbonzini
Cc: kvm, stable, loongarch, linuxppc-dev, caixiangfeng,
fangying.tommy, yanfei.xu, isyanfei.xu, Sashiko
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 <sashiko-bot@kernel•org>
Closes: https://lore.kernel.org/kvm/20260525051714.485D51F000E9@smtp.kernel.org/
Reviewed-by: Harsh Prateek Bora <harshpb@linux•ibm.com>
Signed-off-by: Yanfei Xu <yanfei.xu@bytedance•com>
---
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:
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [v2 0/2] KVM: Validate irqchip index in routing entries
2026-05-31 13:53 [v2 0/2] KVM: Validate irqchip index in routing entries Yanfei Xu
2026-05-31 13:53 ` [v2 1/2] KVM: LoongArch: Validate irqchip index in irqfd routing Yanfei Xu
2026-05-31 13:53 ` [v2 2/2] KVM: PPC: Validate irqchip index in MPIC routing Yanfei Xu
@ 2026-05-31 14:15 ` Greg KH
2026-05-31 14:36 ` Yanfei Xu
2 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2026-05-31 14:15 UTC (permalink / raw)
To: Yanfei Xu
Cc: harshpb, zhaotianrui, maobibo, chenhuacai, maddy, npiggin,
sashiko-reviews, seanjc, pbonzini, kvm, stable, loongarch,
linuxppc-dev, caixiangfeng, fangying.tommy, isyanfei.xu
On Sun, May 31, 2026 at 09:53:24PM +0800, Yanfei Xu wrote:
> Validate irqchip indexes for LoongArch and PowerPC irq routing entries
> to reject out-of-range values before indexing the irqchip array.
>
> v1->v2:
> - Split the patch into two by architecture (Sean)
> - Pick up Reviewed-by
>
> Yanfei Xu (2):
> KVM: LoongArch: Validate irqchip index in irqfd routing
> KVM: PPC: Validate irqchip index in MPIC routing
>
> arch/loongarch/kvm/irqfd.c | 3 ++-
> arch/powerpc/kvm/mpic.c | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> --
> 2.20.1
>
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [v2 0/2] KVM: Validate irqchip index in routing entries
2026-05-31 14:15 ` [v2 0/2] KVM: Validate irqchip index in routing entries Greg KH
@ 2026-05-31 14:36 ` Yanfei Xu
2026-05-31 15:25 ` Greg KH
0 siblings, 1 reply; 7+ messages in thread
From: Yanfei Xu @ 2026-05-31 14:36 UTC (permalink / raw)
To: Greg KH, Yanfei Xu
Cc: harshpb, zhaotianrui, maobibo, chenhuacai, maddy, npiggin,
sashiko-reviews, seanjc, pbonzini, kvm, stable, loongarch,
linuxppc-dev, caixiangfeng, fangying.tommy
On 2026/5/31 22:15, Greg KH wrote:
>> --
>> 2.20.1
>>
> <formletter>
>
> This is not the correct way to submit patches for inclusion in the
> stable kernel tree. Please read:
> https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
> for how to do this properly.
>
> </formletter>
Thanks for pointing out the correct process. I saw
that PPC maintainer added "Cc: stable@vger•kernel.org"
on v1, so I mistakenly thought v2 should cc...
Thanks,
Yanfei
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [v2 0/2] KVM: Validate irqchip index in routing entries
2026-05-31 14:36 ` Yanfei Xu
@ 2026-05-31 15:25 ` Greg KH
0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2026-05-31 15:25 UTC (permalink / raw)
To: Yanfei Xu
Cc: Yanfei Xu, harshpb, zhaotianrui, maobibo, chenhuacai, maddy,
npiggin, sashiko-reviews, seanjc, pbonzini, kvm, stable,
loongarch, linuxppc-dev, caixiangfeng, fangying.tommy
On Sun, May 31, 2026 at 10:36:27PM +0800, Yanfei Xu wrote:
>
> On 2026/5/31 22:15, Greg KH wrote:
> > > --
> > > 2.20.1
> > >
> > <formletter>
> >
> > This is not the correct way to submit patches for inclusion in the
> > stable kernel tree. Please read:
> > https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
> > for how to do this properly.
> >
> > </formletter>
>
> Thanks for pointing out the correct process. I saw
> that PPC maintainer added "Cc: stable@vger•kernel.org"
> on v1, so I mistakenly thought v2 should cc...
That's great, then take a look at the file above to show you how to do
that :)
^ permalink raw reply [flat|nested] 7+ messages in thread