Re:Re: [PATCH] pinctrl: at91: Fix potential use-after-free on manual unbind
From: 李广硕
Date: Tue Nov 24 2026 - 09:05:03 EST
Hi Nicolas,
Thanks for the review.
From: Nicolas.Ferre@xxxxxxxxxxxxx
Date: 2026-11-22 21:00:37
To: liguangshuo@xxxxxxxxxxxxxxx,Ludovic.Desroches@xxxxxxxxxxxxx,linusw@xxxxxxxxxx,alexandre.belloni@xxxxxxxxxxx,claudiu.beznea@xxxxxxxxx
Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx,linux-gpio@xxxxxxxxxxxxxxx,linux-kernel@xxxxxxxxxxxxxxx,stable@xxxxxxxxxxxxxxx
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@xxxxxxxxxxxxxxx
>> Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
>> ---
>> 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