powerpc: Fix integer underflow & leak
Subsystems (2)
cover powerpc: Fix integer underflow & leak
Hi,
This series fixes integer overflow & leak problem. I noticed this problem when Gautam reported a kernel bug with another patch series of mine:
https://lore.kernel.org/linuxppc-dev/[email protected]/
The root cause of that report is a bug in that series. However, that bug triggered another existing bug, causing the reported end results.
Nam Cao (2):
powerpc/pseries/msi: Fix potential underflow and leak issue powerpc/powernv/pci: Fix underflow and leak issue
arch/powerpc/platforms/powernv/pci-ioda.c | 2 +- arch/powerpc/platforms/pseries/msi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.5
PATCH 1/2 powerpc/pseries/msi: Fix potential underflow and leak issue
pseries_irq_domain_alloc() allocates interrupts at parent's interrupt domain. If it fails in the progress, all allocated interrupts are freed.
The number of successfully allocated interrupts so far is stored "i". However, "i - 1" interrupts are freed. This is broken:
- One interrupt is not be freed
- If "i" is zero, "i - 1" wraps around
Correct the number of freed interrupts to 'i'.
--- arch/powerpc/platforms/pseries/msi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/pseries/msi.c +1 -1
@@ -593,7 +593,7 @@ static int pseries_irq_domain_alloc(struct irq_domain *domain, unsigned int virq out:/* TODO: handle RTAS cleanup in ->msi_finish() ? */ -irq_domain_free_irqs_parent (domain, virq, i -1 ); +irq_domain_free_irqs_parent (domain, virq, i);return ret; }
Signature · 1 line
2.39.5
Re: [PATCH 1/2] powerpc/pseries/msi: Fix potential underflow and leak issue
Quoted 11 lines · Nam Cao
pseries_irq_domain_alloc()allocates interrupts at parent's interrupt domain. If it fails in the progress, all allocated interrupts are freed.The number of successfully allocated interrupts so far is stored "i". However, "i - 1" interrupts are freed. This is broken:
- One interrupt is not be freed
- If "i" is zero, "i - 1" wraps around
Quoted 8 lines
Correct the number of freed interrupts to 'i'.
Fixes a5f3d2c17b07 ("powerpc/pseries/pci: Add MSI domains")Signed-off-by Nam Cao <[email protected]>--- arch/powerpc/platforms/pseries/msi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks,
C.
PATCH 2/2 powerpc/powernv/pci: Fix underflow and leak issue
In reply to Nam Caopnv_irq_domain_alloc() allocates interrupts at parent's interrupt domain. If it fails in the progress, all allocated interrupts are freed.
The number of successfully allocated interrupts so far is stored "i". However, "i - 1" interrupts are freed. This is broken:
- One interrupt is not be freed
- If "i" is zero, "i - 1" wraps around
Correct the number of freed interrupts to "i".
--- arch/powerpc/platforms/powernv/pci-ioda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/powernv/pci-ioda.c +1 -1
@@ -1854,7 +1854,7 @@ static int pnv_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,return 0 ; out: -irq_domain_free_irqs_parent (domain, virq, i -1 ); +irq_domain_free_irqs_parent (domain, virq, i);msi_bitmap_free_hwirqs (&phb->msi_bmp, hwirq, nr_irqs);return ret; }
Signature · 1 line
2.39.5
Re: [PATCH 2/2] powerpc/powernv/pci: Fix underflow and leak issue
Quoted 11 lines · Nam Cao
pnv_irq_domain_alloc()allocates interrupts at parent's interrupt domain. If it fails in the progress, all allocated interrupts are freed.The number of successfully allocated interrupts so far is stored "i". However, "i - 1" interrupts are freed. This is broken:
- One interrupt is not be freed
- If "i" is zero, "i - 1" wraps around
Quoted 8 lines
Correct the number of freed interrupts to "i".
Fixes 0fcfe2247e75 ("powerpc/powernv/pci: Add MSI domains")Signed-off-by Nam Cao <[email protected]>--- arch/powerpc/platforms/powernv/pci-ioda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks,
C.
Quoted 8 lines · Nam Cao
This series fixes integer overflow & leak problem. I noticed this problem when Gautam reported a kernel bug with another patch series of mine:
https://lore.kernel.org/linuxppc-dev/[email protected]/The root cause of that report is a bug in that series. However, that bug triggered another existing bug, causing the reported end results.
[...]
Applied to powerpc/next.
[1/2] powerpc/pseries/msi: Fix potential underflow and leak issue
https://git.kernel.org/powerpc/c/3443ff3be6e59b80d74036bb39f5b6409eb23cc9 [2/2] powerpc/powernv/pci: Fix underflow and leak issue https://git.kernel.org/powerpc/c/a39087905af9ffecaa237a918a2c03a04e479934
Thanks