All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Artem Dinaburg" <artem@trailofbits.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH 6.6.y 2/2] gpio: rockchip: fix generic IRQ chip leak on remove
Date: Thu, 08 Oct 2026 19:30:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-164526@kernel.org> (raw)
In-Reply-To: <20261008191824.98662-3-artem@trailofbits.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] gpio: rockchip: UAF in rockchip_gpio_to_irq due to teardown order
- [High] gpio: rockchip: missing irq mapping disposal causes UAF
--

commit 7ad98fc33c5f3a1c30b1b0722c11e01bbf5172c9
Author: Marco Scardovi <scardracs@disroot.org>
Subject: gpio: rockchip: fix generic IRQ chip leak on remove

This patch addresses a resource leak by explicitly removing the generic
chips and the IRQ domain in rockchip_gpio_remove().

Link: https://patch.msgid.link/20260607230504.35392-2-scardracs@disroot.org

> diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
> index e0e4f3ed5fdd4..86cf3cbcdb403 100644
> --- a/drivers/gpio/gpio-rockchip.c
> +++ b/drivers/gpio/gpio-rockchip.c
> @@ -786,8 +786,10 @@ static int rockchip_gpio_remove(struct platform_device *pdev)
>  	struct rockchip_pin_bank *bank = platform_get_drvdata(pdev);
>  
>  	irq_set_chained_handler_and_data(bank->irq, NULL, NULL);
> -	if (bank->domain)
> +	if (bank->domain) {
> +		irq_domain_remove_generic_chips(bank->domain);
>  		irq_domain_remove(bank->domain);

[Severity: High]
Does removing the IRQ domain before calling gpiochip_remove() introduce a
use-after-free race condition?

Because the GPIO chip is still registered and active in gpiolib, concurrent
operations (like a sysfs write configuring an edge trigger) can still invoke
gpiod_to_irq(). This triggers the driver's .to_irq callback:

rockchip_gpio_to_irq() {
    ...
    virq = irq_create_mapping(bank->domain, offset);
    ...
}

Since bank->domain has already been freed, this will dereference a dangling
pointer. Would reversing the teardown order to call gpiochip_remove() before
freeing the domain unregister sysfs nodes, drain pending operations, and
safely close this race window?

[Severity: High]
Does removing the IRQ domain here without disposing of active mappings leak
those mappings and cause a use-after-free in the core IRQ subsystem?

When the domain is removed without iterating over active pins to call
irq_dispose_mapping(), the core IRQ code hits a warning:

irq_domain_remove() {
    ...
    WARN_ON(!radix_tree_empty(&domain->revmap_tree));
    ...
    irq_domain_free(domain);
}

Active IRQ descriptors will retain a dangling pointer to the freed domain in
their irq_data->domain fields. When consumer drivers subsequently unbind and
free their IRQ, irq_dispose_mapping() accesses the freed domain pointer to
check hierarchy flags, leading to a crash.

Should the active mappings be disposed of before removing the domain?

> +	}
>  	gpiochip_remove(&bank->gpio_chip);
>  
>  	return 0;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261008191824.98662-1-artem@trailofbits.com?part=2

  reply	other threads:[~2026-10-08 19:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08 19:18 [PATCH 6.6.y 0/2] gpio: backport CVE-2026-53226, CVE-2026-64241 Artem Dinaburg
2026-10-08 19:18 ` Artem Dinaburg
2026-10-08 19:18 ` [PATCH 6.6.y 1/2] gpio: rockchip: teardown bugs and resource leaks Artem Dinaburg
2026-10-08 19:18   ` Artem Dinaburg
2026-10-08 19:28   ` sashiko-bot
2026-10-08 19:18 ` [PATCH 6.6.y 2/2] gpio: rockchip: fix generic IRQ chip leak on remove Artem Dinaburg
2026-10-08 19:18   ` Artem Dinaburg
2026-10-08 19:30   ` sashiko-bot [this message]
2026-10-09 17:09 ` [PATCH 6.6.y 0/2] gpio: backport CVE-2026-53226, CVE-2026-64241 Sasha Levin
2026-10-09 17:09   ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-164526@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=artem@trailofbits.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.