Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: at91: Fix potential use-after-free on manual unbind
@ 2026-11-20 17:35 Guangshuo Li
  2026-11-22 13:00 ` Nicolas.Ferre
  0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-11-20 17:35 UTC (permalink / raw)
  To: Ludovic Desroches, Linus Walleij, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea
  Cc: linux-arm-kernel, linux-gpio, linux-kernel, stable

The built-in GPIO and pinctrl drivers share GPIO ranges and global bank
pointers but provide no teardown for those relationships. Manually
unbinding a GPIO bank frees its private data while pinctrl still holds
its embedded range, which is accessed during pinctrl cleanup.

Suppress the bind attributes for these non-removable SoC controllers
so userspace cannot trigger this unsupported teardown.

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

Fixes: 6732ae5cb47c ("ARM: at91: add pinctrl support")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/pinctrl/pinctrl-at91.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 0a57ed51d4c9..81b58a7a44be 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -1911,6 +1911,7 @@ static DEFINE_NOIRQ_DEV_PM_OPS(at91_gpio_pm_ops, at91_gpio_suspend, at91_gpio_re
 static struct platform_driver at91_gpio_driver = {
 	.driver = {
 		.name = "gpio-at91",
+		.suppress_bind_attrs = true,
 		.of_match_table = at91_gpio_of_match,
 		.pm = pm_sleep_ptr(&at91_gpio_pm_ops),
 	},
@@ -1920,6 +1921,7 @@ static struct platform_driver at91_gpio_driver = {
 static struct platform_driver at91_pinctrl_driver = {
 	.driver = {
 		.name = "pinctrl-at91",
+		.suppress_bind_attrs = true,
 		.of_match_table = at91_pinctrl_of_match,
 	},
 	.probe = at91_pinctrl_probe,

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4


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

* Re: [PATCH] pinctrl: at91: Fix potential use-after-free on manual unbind
  2026-11-20 17:35 [PATCH] pinctrl: at91: Fix potential use-after-free on manual unbind Guangshuo Li
@ 2026-11-22 13:00 ` Nicolas.Ferre
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas.Ferre @ 2026-11-22 13:00 UTC (permalink / raw)
  To: liguangshuo, Ludovic.Desroches, linusw, alexandre.belloni,
	claudiu.beznea
  Cc: linux-arm-kernel, linux-gpio, linux-kernel, stable

On 20/11/2026 at 18:35, Guangshuo Li wrote:
> The built-in GPIO and pinctrl drivers share GPIO ranges and global bank
> pointers but provide no teardown for those relationships. Manually
> unbinding a GPIO bank frees its private data while pinctrl still holds
> its embedded range, which is accessed during pinctrl cleanup.
> 
> Suppress the bind attributes for these non-removable SoC controllers
> so userspace cannot trigger this unsupported teardown.
> 
> This issue was found by our static analysis tool under development.

Well, who will ever want to remove gpio or pinctrl on these platforms, 
knowing that it's one and only IP for the two?
Does it have a real use-case?
I don't see the point.

Regards,
   Nicolas

> Fixes: 6732ae5cb47c ("ARM: at91: add pinctrl support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
> ---
>   drivers/pinctrl/pinctrl-at91.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
> index 0a57ed51d4c9..81b58a7a44be 100644
> --- a/drivers/pinctrl/pinctrl-at91.c
> +++ b/drivers/pinctrl/pinctrl-at91.c
> @@ -1911,6 +1911,7 @@ static DEFINE_NOIRQ_DEV_PM_OPS(at91_gpio_pm_ops, at91_gpio_suspend, at91_gpio_re
>   static struct platform_driver at91_gpio_driver = {
>          .driver = {
>                  .name = "gpio-at91",
> +               .suppress_bind_attrs = true,
>                  .of_match_table = at91_gpio_of_match,
>                  .pm = pm_sleep_ptr(&at91_gpio_pm_ops),
>          },
> @@ -1920,6 +1921,7 @@ static struct platform_driver at91_gpio_driver = {
>   static struct platform_driver at91_pinctrl_driver = {
>          .driver = {
>                  .name = "pinctrl-at91",
> +               .suppress_bind_attrs = true,
>                  .of_match_table = at91_pinctrl_of_match,
>          },
>          .probe = at91_pinctrl_probe,
> 
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4


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

end of thread, other threads:[~2026-11-22 13:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 17:35 [PATCH] pinctrl: at91: Fix potential use-after-free on manual unbind Guangshuo Li
2026-11-22 13:00 ` Nicolas.Ferre

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