mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gpio: brcmstb: fix UAF after IRQ domain setup failure
@ 2026-10-26 11:52 Guangshuo Li
  2026-10-27 22:55 ` Florian Fainelli
  2026-10-28  9:35 ` Bartosz Golaszewski
  0 siblings, 2 replies; 3+ messages in thread
From: Guangshuo Li @ 2026-10-26 11:52 UTC (permalink / raw)
  To: Doug Berger, Florian Fainelli,
	Broadcom internal kernel review list, Linus Walleij,
	Bartosz Golaszewski, Gregory Fong, linux-gpio, linux-arm-kernel,
	linux-kernel
  Cc: Guangshuo Li, stable

When devm_request_irq() fails in brcmstb_gpio_irq_setup(), the error
path removes the IRQ domain but leaves priv->irq_domain non-NULL.

The probe error path subsequently calls brcmstb_gpio_remove(), which
checks priv->irq_domain and attempts to access the already-freed
domain through irq_find_mapping(). It also attempts to remove the
domain again, resulting in a use-after-free and potentially further
memory corruption.

Set priv->irq_domain to NULL after removing it so that the common
cleanup path skips the already-freed IRQ domain.

This issue was found by our static analysis tool under development.

Fixes: 0ba31dc201de ("gpio: brcmstb: consolidate interrupt domains")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/gpio/gpio-brcmstb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c
index 44ca798cf832..3b1aaea63951 100644
--- a/drivers/gpio/gpio-brcmstb.c
+++ b/drivers/gpio/gpio-brcmstb.c
@@ -513,6 +513,7 @@ static int brcmstb_gpio_irq_setup(struct platform_device *pdev,
 
 out_free_domain:
 	irq_domain_remove(priv->irq_domain);
+	priv->irq_domain = NULL;
 
 	return err;
 }
-- 
2.43.0


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

* Re: [PATCH] gpio: brcmstb: fix UAF after IRQ domain setup failure
  2026-10-26 11:52 [PATCH] gpio: brcmstb: fix UAF after IRQ domain setup failure Guangshuo Li
@ 2026-10-27 22:55 ` Florian Fainelli
  2026-10-28  9:35 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2026-10-27 22:55 UTC (permalink / raw)
  To: Guangshuo Li, Doug Berger, Broadcom internal kernel review list,
	Linus Walleij, Bartosz Golaszewski, Gregory Fong, linux-gpio,
	linux-arm-kernel, linux-kernel
  Cc: stable

On 10/26/26 04:52, Guangshuo Li wrote:
> When devm_request_irq() fails in brcmstb_gpio_irq_setup(), the error
> path removes the IRQ domain but leaves priv->irq_domain non-NULL.
> 
> The probe error path subsequently calls brcmstb_gpio_remove(), which
> checks priv->irq_domain and attempts to access the already-freed
> domain through irq_find_mapping(). It also attempts to remove the
> domain again, resulting in a use-after-free and potentially further
> memory corruption.
> 
> Set priv->irq_domain to NULL after removing it so that the common
> cleanup path skips the already-freed IRQ domain.
> 
> This issue was found by our static analysis tool under development.
> 
> Fixes: 0ba31dc201de ("gpio: brcmstb: consolidate interrupt domains")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
-- 
Florian

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

* Re: [PATCH] gpio: brcmstb: fix UAF after IRQ domain setup failure
  2026-10-26 11:52 [PATCH] gpio: brcmstb: fix UAF after IRQ domain setup failure Guangshuo Li
  2026-10-27 22:55 ` Florian Fainelli
@ 2026-10-28  9:35 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2026-10-28  9:35 UTC (permalink / raw)
  To: Doug Berger, Florian Fainelli,
	Broadcom internal kernel review list, Linus Walleij,
	Bartosz Golaszewski, Gregory Fong, linux-gpio, linux-arm-kernel,
	linux-kernel, Guangshuo Li
  Cc: Bartosz Golaszewski, stable


On Mon, 26 Oct 2026 19:52:26 +0800, Guangshuo Li wrote:
> When devm_request_irq() fails in brcmstb_gpio_irq_setup(), the error
> path removes the IRQ domain but leaves priv->irq_domain non-NULL.
> 
> The probe error path subsequently calls brcmstb_gpio_remove(), which
> checks priv->irq_domain and attempts to access the already-freed
> domain through irq_find_mapping(). It also attempts to remove the
> domain again, resulting in a use-after-free and potentially further
> memory corruption.
> 
> [...]

Applied, thanks!

[1/1] gpio: brcmstb: fix UAF after IRQ domain setup failure
      https://git.kernel.org/brgl/c/baa14758afb3e2828de1f76511edc1de50216f39

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

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

end of thread, other threads:[~2026-10-28  9:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26 11:52 [PATCH] gpio: brcmstb: fix UAF after IRQ domain setup failure Guangshuo Li
2026-10-27 22:55 ` Florian Fainelli
2026-10-28  9:35 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®