linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] powerpc: Fix integer underflow & leak
@ 2025-08-04 10:07 Nam Cao
  2025-08-04 10:07 ` [PATCH 1/2] powerpc/pseries/msi: Fix potential underflow and leak issue Nam Cao
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Nam Cao @ 2025-08-04 10:07 UTC (permalink / raw)
  To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Gautam Menghani, Cédric Le Goater,
	linuxppc-dev, linux-kernel
  Cc: Nam Cao

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/aH9Na8ZqrI0jPhtl@li-c6426e4c-27cf-11b2-a85c-95d65bc0de0e.ibm.com/

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(-)

-- 
2.39.5



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] powerpc/pseries/msi: Fix potential underflow and leak issue
  2025-08-04 10:07 [PATCH 0/2] powerpc: Fix integer underflow & leak Nam Cao
@ 2025-08-04 10:07 ` Nam Cao
  2025-08-04 10:18   ` Cédric Le Goater
  2025-08-04 10:07 ` [PATCH 2/2] powerpc/powernv/pci: Fix " Nam Cao
  2025-09-06 10:07 ` [PATCH 0/2] powerpc: Fix integer underflow & leak Madhavan Srinivasan
  2 siblings, 1 reply; 6+ messages in thread
From: Nam Cao @ 2025-08-04 10:07 UTC (permalink / raw)
  To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Gautam Menghani, Cédric Le Goater,
	linuxppc-dev, linux-kernel
  Cc: Nam Cao, stable

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'.

Fixes: a5f3d2c17b07 ("powerpc/pseries/pci: Add MSI domains")
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: stable@vger.kernel.org
---
 arch/powerpc/platforms/pseries/msi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/msi.c b/arch/powerpc/platforms/pseries/msi.c
index ee1c8c6898a3..9dc294de631f 100644
--- a/arch/powerpc/platforms/pseries/msi.c
+++ b/arch/powerpc/platforms/pseries/msi.c
@@ -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;
 }
 
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] powerpc/powernv/pci: Fix underflow and leak issue
  2025-08-04 10:07 [PATCH 0/2] powerpc: Fix integer underflow & leak Nam Cao
  2025-08-04 10:07 ` [PATCH 1/2] powerpc/pseries/msi: Fix potential underflow and leak issue Nam Cao
@ 2025-08-04 10:07 ` Nam Cao
  2025-08-04 10:18   ` Cédric Le Goater
  2025-09-06 10:07 ` [PATCH 0/2] powerpc: Fix integer underflow & leak Madhavan Srinivasan
  2 siblings, 1 reply; 6+ messages in thread
From: Nam Cao @ 2025-08-04 10:07 UTC (permalink / raw)
  To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Gautam Menghani, Cédric Le Goater,
	linuxppc-dev, linux-kernel
  Cc: Nam Cao, stable

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

Correct the number of freed interrupts to "i".

Fixes: 0fcfe2247e75 ("powerpc/powernv/pci: Add MSI domains")
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: stable@vger.kernel.org
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index d8ccf2c9b98a..0166bf39ce1e 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -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;
 }
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] powerpc/pseries/msi: Fix potential underflow and leak issue
  2025-08-04 10:07 ` [PATCH 1/2] powerpc/pseries/msi: Fix potential underflow and leak issue Nam Cao
@ 2025-08-04 10:18   ` Cédric Le Goater
  0 siblings, 0 replies; 6+ messages in thread
From: Cédric Le Goater @ 2025-08-04 10:18 UTC (permalink / raw)
  To: Nam Cao, Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Gautam Menghani, linuxppc-dev, linux-kernel
  Cc: stable

On 8/4/25 12:07, Nam Cao wrote:
> 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'.
> 
> Fixes: a5f3d2c17b07 ("powerpc/pseries/pci: Add MSI domains")
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> Cc: stable@vger.kernel.org
> ---
>   arch/powerpc/platforms/pseries/msi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)



Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] powerpc/powernv/pci: Fix underflow and leak issue
  2025-08-04 10:07 ` [PATCH 2/2] powerpc/powernv/pci: Fix " Nam Cao
@ 2025-08-04 10:18   ` Cédric Le Goater
  0 siblings, 0 replies; 6+ messages in thread
From: Cédric Le Goater @ 2025-08-04 10:18 UTC (permalink / raw)
  To: Nam Cao, Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Gautam Menghani, linuxppc-dev, linux-kernel
  Cc: stable

On 8/4/25 12:07, Nam Cao wrote:
> 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
> 
> Correct the number of freed interrupts to "i".
> 
> Fixes: 0fcfe2247e75 ("powerpc/powernv/pci: Add MSI domains")
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> Cc: stable@vger.kernel.org
> ---
>   arch/powerpc/platforms/powernv/pci-ioda.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] powerpc: Fix integer underflow & leak
  2025-08-04 10:07 [PATCH 0/2] powerpc: Fix integer underflow & leak Nam Cao
  2025-08-04 10:07 ` [PATCH 1/2] powerpc/pseries/msi: Fix potential underflow and leak issue Nam Cao
  2025-08-04 10:07 ` [PATCH 2/2] powerpc/powernv/pci: Fix " Nam Cao
@ 2025-09-06 10:07 ` Madhavan Srinivasan
  2 siblings, 0 replies; 6+ messages in thread
From: Madhavan Srinivasan @ 2025-09-06 10:07 UTC (permalink / raw)
  To: Michael Ellerman, Nicholas Piggin, Christophe Leroy,
	Gautam Menghani, Cédric Le Goater, linuxppc-dev,
	linux-kernel, Nam Cao

On Mon, 04 Aug 2025 12:07:26 +0200, Nam Cao wrote:
> 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/aH9Na8ZqrI0jPhtl@li-c6426e4c-27cf-11b2-a85c-95d65bc0de0e.ibm.com/
> 
> 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-09-06 10:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-04 10:07 [PATCH 0/2] powerpc: Fix integer underflow & leak Nam Cao
2025-08-04 10:07 ` [PATCH 1/2] powerpc/pseries/msi: Fix potential underflow and leak issue Nam Cao
2025-08-04 10:18   ` Cédric Le Goater
2025-08-04 10:07 ` [PATCH 2/2] powerpc/powernv/pci: Fix " Nam Cao
2025-08-04 10:18   ` Cédric Le Goater
2025-09-06 10:07 ` [PATCH 0/2] powerpc: Fix integer underflow & leak Madhavan Srinivasan

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).