All of 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
  2026-12-01 10:41 ` Linus Walleij
  0 siblings, 2 replies; 4+ 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] 4+ 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
  2026-11-24 14:03   ` 李广硕
  2026-12-01 10:41 ` Linus Walleij
  1 sibling, 1 reply; 4+ 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] 4+ messages in thread

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


Hi Nicolas,

Thanks for the review.

From: Nicolas.Ferre@microchip.com
Date: 2026-11-22 21:00:37
To:  liguangshuo@mail.sdu.edu.cn,Ludovic.Desroches@microchip.com,linusw@kernel.org,alexandre.belloni@bootlin.com,claudiu.beznea@tuxon.dev
Cc:  linux-arm-kernel@lists.infradead.org,linux-gpio@vger.kernel.org,linux-kernel@vger.kernel.org,stable@vger.kernel.org
Subject: Re: [PATCH] pinctrl: at91: Fix potential use-after-free on manual unbind>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
>

I don't have a use case that needs these controllers to be unbound.
The intention was to make the sysfs interface match the drivers' lack
of teardown support: unbind is exposed, but neither driver removes the
shared GPIO ranges and bank pointers.

Would suppressing that unsupported interface be useful here, or would
you prefer to leave it unchanged?

Thanks,
Guangshuo

^ permalink raw reply	[flat|nested] 4+ 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
@ 2026-12-01 10:41 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2026-12-01 10:41 UTC (permalink / raw)
  To: Guangshuo Li
  Cc: Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, linux-arm-kernel, linux-gpio, linux-kernel,
	stable

On Fri, Nov 20, 2026 at 6:35 PM Guangshuo Li
<liguangshuo@mail.sdu.edu.cn> 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.
>
> Fixes: 6732ae5cb47c ("ARM: at91: add pinctrl support")
> Cc: stable@vger.kernel.org

No way. It's not that serious. I'm dropping this tag.

> Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>

Patch applied as Nicolas confirms no sane person would
unbind this driver and that is what is being suppressed.

Yours,
Linus Walleij

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

end of thread, other threads:[~2026-12-01 10:41 UTC | newest]

Thread overview: 4+ 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
2026-11-24 14:03   ` 李广硕
2026-12-01 10:41 ` Linus Walleij

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.