* [WRONG] KVM: arm/arm64: vgic: fix off-by-one bug in vgic_get_irq()
@ 2018-12-19 15:11 Gustavo A. R. Silva
2018-12-19 16:14 ` Marc Zyngier
0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2018-12-19 15:11 UTC (permalink / raw)
To: Christoffer Dall, Marc Zyngier, Mark Rutland
Cc: stable, Gustavo A. R. Silva, kvmarm, linux-arm-kernel,
linux-kernel
Hi Marc,
This is wrong: commit 6022fcc0e87a0eb5e9a72b15ed70dd29ebcb7343
The above is not my original patch and it should not be tagged for stable,
as it introduces the same kind of bug I intended to fix:
array_index_nospec() can now return kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS
and this is not what you want. So, in this case the following line of code
is just fine as it is:
intid = array_index_nospec(intid, kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS);
As the commit log says, my patch fixes:
commit 41b87599c74300027f305d7b34368ec558978ff2
not both:
commit 41b87599c74300027f305d7b34368ec558978ff2
and
commit bea2ef803ade3359026d5d357348842bca9edcf1
If you want to apply the fix on top of bea2ef803ade3359026d5d357348842bca9edcf1
then you should apply this instead:
diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c
index bb1a83345741..e607547c7bb0 100644
--- a/virt/kvm/arm/vgic/vgic.c
+++ b/virt/kvm/arm/vgic/vgic.c
@@ -103,7 +103,7 @@ struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu,
{
/* SGIs and PPIs */
if (intid <= VGIC_MAX_PRIVATE) {
- intid = array_index_nospec(intid, VGIC_MAX_PRIVATE);
+ intid = array_index_nospec(intid, VGIC_MAX_PRIVATE + 1);
return &vcpu->arch.vgic_cpu.private_irqs[intid];
}
The commit log should remain the same.
Thanks
--
Gustavo
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [WRONG] KVM: arm/arm64: vgic: fix off-by-one bug in vgic_get_irq()
2018-12-19 15:11 [WRONG] KVM: arm/arm64: vgic: fix off-by-one bug in vgic_get_irq() Gustavo A. R. Silva
@ 2018-12-19 16:14 ` Marc Zyngier
0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2018-12-19 16:14 UTC (permalink / raw)
To: Gustavo A. R. Silva, Christoffer Dall, Mark Rutland
Cc: stable, kvmarm, linux-arm-kernel, linux-kernel
Hi Gustavo,
On 19/12/2018 15:11, Gustavo A. R. Silva wrote:
> Hi Marc,
>
> This is wrong: commit 6022fcc0e87a0eb5e9a72b15ed70dd29ebcb7343
>
> The above is not my original patch and it should not be tagged for stable,
> as it introduces the same kind of bug I intended to fix:
>
> array_index_nospec() can now return kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS
> and this is not what you want. So, in this case the following line of code
> is just fine as it is:
>
> intid = array_index_nospec(intid, kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS);
>
>
> As the commit log says, my patch fixes:
>
> commit 41b87599c74300027f305d7b34368ec558978ff2
>
> not both:
>
> commit 41b87599c74300027f305d7b34368ec558978ff2
>
> and
>
> commit bea2ef803ade3359026d5d357348842bca9edcf1
>
> If you want to apply the fix on top of bea2ef803ade3359026d5d357348842bca9edcf1
> then you should apply this instead:
>
> diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c
> index bb1a83345741..e607547c7bb0 100644
> --- a/virt/kvm/arm/vgic/vgic.c
> +++ b/virt/kvm/arm/vgic/vgic.c
> @@ -103,7 +103,7 @@ struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu,
> {
> /* SGIs and PPIs */
> if (intid <= VGIC_MAX_PRIVATE) {
> - intid = array_index_nospec(intid, VGIC_MAX_PRIVATE);
> + intid = array_index_nospec(intid, VGIC_MAX_PRIVATE + 1);
> return &vcpu->arch.vgic_cpu.private_irqs[intid];
> }
>
>
> The commit log should remain the same.
I indeed completely fscked up the conflict resolution, clearly not
engaging my brain. I'll fix that quickly.
Thanks for the heads up.
M.
--
Jazz is not dead. It just smells funny...
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-19 16:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-19 15:11 [WRONG] KVM: arm/arm64: vgic: fix off-by-one bug in vgic_get_irq() Gustavo A. R. Silva
2018-12-19 16:14 ` Marc Zyngier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).