* [PATCH] usb: musb: fix use-after-free in musb_remove()
@ 2026-11-07 11:46 Joshua Crofts
2026-11-07 11:56 ` sashiko-bot
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Joshua Crofts @ 2026-11-07 11:46 UTC (permalink / raw)
To: Bin Liu, Greg Kroah-Hartman, Uwe Kleine-König, Felipe Balbi
Cc: linux-usb, linux-kernel, Sashiko, stable, Joshua Crofts
Currently in musb_remove(), musb_platform_exit() drops the PHY refcount
before usb_phy_shutdown() is called, causing a use-after-free bug.
Reorder the function so that usb_phy_shutdown() is called before
musb_platform_exit(), the same way as musb_init_controller() does in the
error path.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-d180c2b9-0006-4638-a22b-13df8c201235
Fixes: 39cee200c23e ("usb: musb: core: call init and shutdown for the usb phy")
Cc: stable@vger.kernel.org
Signed-off-by: Joshua Crofts <crofts@kernel.org>
---
drivers/usb/musb/musb_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 73ac25f53698..8e52246de948 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2642,6 +2642,7 @@ static void musb_remove(struct platform_device *pdev)
musb_disable_interrupts(musb);
musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
spin_unlock_irqrestore(&musb->lock, flags);
+ usb_phy_shutdown(musb->xceiv);
musb_platform_exit(musb);
pm_runtime_dont_use_autosuspend(musb->controller);
@@ -2650,7 +2651,6 @@ static void musb_remove(struct platform_device *pdev)
musb_phy_callback = NULL;
if (musb->dma_controller)
musb_dma_controller_destroy(musb->dma_controller);
- usb_phy_shutdown(musb->xceiv);
musb_free(musb);
device_init_wakeup(dev, 0);
}
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261107-usb-uaf-fix-bedcd9cd8f4b
Best regards,
--
Joshua Crofts
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: musb: fix use-after-free in musb_remove()
2026-11-07 11:46 [PATCH] usb: musb: fix use-after-free in musb_remove() Joshua Crofts
@ 2026-11-07 11:56 ` sashiko-bot
2026-11-20 14:11 ` Greg Kroah-Hartman
2026-11-20 14:47 ` Greg Kroah-Hartman
2 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-07 11:56 UTC (permalink / raw)
To: Joshua Crofts; +Cc: linux-usb
> Currently in musb_remove(), musb_platform_exit() drops the PHY refcount
> before usb_phy_shutdown() is called, causing a use-after-free bug.
>
> Reorder the function so that usb_phy_shutdown() is called before
> musb_platform_exit(), the same way as musb_init_controller() does in the
> error path.
>
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/bug/linux-d180c2b9-0006-4638-a22b-13df8c201235
> Fixes: 39cee200c23e ("usb: musb: core: call init and shutdown for the usb phy")
> Cc: stable@vger.kernel.org
> Signed-off-by: Joshua Crofts <crofts@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261107-usb-uaf-fix-v1-1-ba33689d0ca3@kernel.org?part=1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: musb: fix use-after-free in musb_remove()
2026-11-07 11:46 [PATCH] usb: musb: fix use-after-free in musb_remove() Joshua Crofts
2026-11-07 11:56 ` sashiko-bot
@ 2026-11-20 14:11 ` Greg Kroah-Hartman
2026-11-20 14:25 ` Joshua Crofts
2026-11-20 14:47 ` Greg Kroah-Hartman
2 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2026-11-20 14:11 UTC (permalink / raw)
To: Joshua Crofts
Cc: Bin Liu, Uwe Kleine-König, Felipe Balbi, linux-usb,
linux-kernel, Sashiko, stable
On Sat, Nov 07, 2026 at 12:46:17PM +0100, Joshua Crofts wrote:
> Currently in musb_remove(), musb_platform_exit() drops the PHY refcount
> before usb_phy_shutdown() is called, causing a use-after-free bug.
>
> Reorder the function so that usb_phy_shutdown() is called before
> musb_platform_exit(), the same way as musb_init_controller() does in the
> error path.
>
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/bug/linux-d180c2b9-0006-4638-a22b-13df8c201235
> Fixes: 39cee200c23e ("usb: musb: core: call init and shutdown for the usb phy")
> Cc: stable@vger.kernel.org
> Signed-off-by: Joshua Crofts <crofts@kernel.org>
> ---
> drivers/usb/musb/musb_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index 73ac25f53698..8e52246de948 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -2642,6 +2642,7 @@ static void musb_remove(struct platform_device *pdev)
> musb_disable_interrupts(musb);
> musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
> spin_unlock_irqrestore(&musb->lock, flags);
> + usb_phy_shutdown(musb->xceiv);
> musb_platform_exit(musb);
>
> pm_runtime_dont_use_autosuspend(musb->controller);
> @@ -2650,7 +2651,6 @@ static void musb_remove(struct platform_device *pdev)
> musb_phy_callback = NULL;
> if (musb->dma_controller)
> musb_dma_controller_destroy(musb->dma_controller);
> - usb_phy_shutdown(musb->xceiv);
> musb_free(musb);
> device_init_wakeup(dev, 0);
> }
>
> ---
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
> change-id: 20261107-usb-uaf-fix-bedcd9cd8f4b
>
> Best regards,
> --
> Joshua Crofts
>
Does not apply to the usb-linus branch, please rebase and resend.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: musb: fix use-after-free in musb_remove()
2026-11-20 14:11 ` Greg Kroah-Hartman
@ 2026-11-20 14:25 ` Joshua Crofts
0 siblings, 0 replies; 6+ messages in thread
From: Joshua Crofts @ 2026-11-20 14:25 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Bin Liu, Uwe Kleine-König, Felipe Balbi, linux-usb,
linux-kernel, Sashiko, stable
On 20-Nov-26 15:11, Greg Kroah-Hartman wrote:
> On Sat, Nov 07, 2026 at 12:46:17PM +0100, Joshua Crofts wrote:
>> Currently in musb_remove(), musb_platform_exit() drops the PHY refcount
>> before usb_phy_shutdown() is called, causing a use-after-free bug.
>>
>> Reorder the function so that usb_phy_shutdown() is called before
>> musb_platform_exit(), the same way as musb_init_controller() does in the
>> error path.
...
>>
>
> Does not apply to the usb-linus branch, please rebase and resend.
Sorry, rebased patch here:
https://lore.kernel.org/linux-usb/20261120-usb-uaf-fix-v2-1-cc3cb2a38ad5@kernel.org
--
Kind regards,
Joshua Crofts
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: musb: fix use-after-free in musb_remove()
2026-11-07 11:46 [PATCH] usb: musb: fix use-after-free in musb_remove() Joshua Crofts
2026-11-07 11:56 ` sashiko-bot
2026-11-20 14:11 ` Greg Kroah-Hartman
@ 2026-11-20 14:47 ` Greg Kroah-Hartman
2026-11-20 14:51 ` Joshua Crofts
2 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2026-11-20 14:47 UTC (permalink / raw)
To: Joshua Crofts
Cc: Bin Liu, Uwe Kleine-König, Felipe Balbi, linux-usb,
linux-kernel, Sashiko, stable
On Sat, Nov 07, 2026 at 12:46:17PM +0100, Joshua Crofts wrote:
> Currently in musb_remove(), musb_platform_exit() drops the PHY refcount
> before usb_phy_shutdown() is called, causing a use-after-free bug.
>
> Reorder the function so that usb_phy_shutdown() is called before
> musb_platform_exit(), the same way as musb_init_controller() does in the
> error path.
>
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/bug/linux-d180c2b9-0006-4638-a22b-13df8c201235
> Fixes: 39cee200c23e ("usb: musb: core: call init and shutdown for the usb phy")
> Cc: stable@vger.kernel.org
> Signed-off-by: Joshua Crofts <crofts@kernel.org>
> ---
> drivers/usb/musb/musb_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index 73ac25f53698..8e52246de948 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -2642,6 +2642,7 @@ static void musb_remove(struct platform_device *pdev)
> musb_disable_interrupts(musb);
> musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
> spin_unlock_irqrestore(&musb->lock, flags);
> + usb_phy_shutdown(musb->xceiv);
> musb_platform_exit(musb);
>
> pm_runtime_dont_use_autosuspend(musb->controller);
> @@ -2650,7 +2651,6 @@ static void musb_remove(struct platform_device *pdev)
> musb_phy_callback = NULL;
> if (musb->dma_controller)
> musb_dma_controller_destroy(musb->dma_controller);
> - usb_phy_shutdown(musb->xceiv);
> musb_free(musb);
> device_init_wakeup(dev, 0);
> }
>
> ---
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
> change-id: 20261107-usb-uaf-fix-bedcd9cd8f4b
>
> Best regards,
> --
> Joshua Crofts
>
Does not apply to usb-linus
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: musb: fix use-after-free in musb_remove()
2026-11-20 14:47 ` Greg Kroah-Hartman
@ 2026-11-20 14:51 ` Joshua Crofts
0 siblings, 0 replies; 6+ messages in thread
From: Joshua Crofts @ 2026-11-20 14:51 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Bin Liu, Uwe Kleine-König, Felipe Balbi, linux-usb,
linux-kernel, Sashiko, stable
On 20-Nov-26 15:47, Greg Kroah-Hartman wrote:
> On Sat, Nov 07, 2026 at 12:46:17PM +0100, Joshua Crofts wrote:
>> Currently in musb_remove(), musb_platform_exit() drops the PHY refcount
>> before usb_phy_shutdown() is called, causing a use-after-free bug.
>>
>> Reorder the function so that usb_phy_shutdown() is called before
>> musb_platform_exit(), the same way as musb_init_controller() does in the
>> error path.
>>
>> Reported-by: Sashiko <sashiko-bot@kernel.org>
>> Closes: https://sashiko.dev/#/bug/linux-d180c2b9-0006-4638-a22b-13df8c201235
>> Fixes: 39cee200c23e ("usb: musb: core: call init and shutdown for the usb phy")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Joshua Crofts <crofts@kernel.org>
>> ---
>> drivers/usb/musb/musb_core.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
>> index 73ac25f53698..8e52246de948 100644
>> --- a/drivers/usb/musb/musb_core.c
>> +++ b/drivers/usb/musb/musb_core.c
>> @@ -2642,6 +2642,7 @@ static void musb_remove(struct platform_device *pdev)
>> musb_disable_interrupts(musb);
>> musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
>> spin_unlock_irqrestore(&musb->lock, flags);
>> + usb_phy_shutdown(musb->xceiv);
>> musb_platform_exit(musb);
>>
>> pm_runtime_dont_use_autosuspend(musb->controller);
>> @@ -2650,7 +2651,6 @@ static void musb_remove(struct platform_device *pdev)
>> musb_phy_callback = NULL;
>> if (musb->dma_controller)
>> musb_dma_controller_destroy(musb->dma_controller);
>> - usb_phy_shutdown(musb->xceiv);
>> musb_free(musb);
>> device_init_wakeup(dev, 0);
>> }
>>
>> ---
>> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
>> change-id: 20261107-usb-uaf-fix-bedcd9cd8f4b
>>
>> Best regards,
>> --
>> Joshua Crofts
>>
>
> Does not apply to usb-linus
I already sent a rebased v2:
https://lore.kernel.org/linux-usb/20261120-usb-uaf-fix-v2-1-cc3cb2a38ad5@kernel.org
--
Kind regards,
Joshua Crofts
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-20 14:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-07 11:46 [PATCH] usb: musb: fix use-after-free in musb_remove() Joshua Crofts
2026-11-07 11:56 ` sashiko-bot
2026-11-20 14:11 ` Greg Kroah-Hartman
2026-11-20 14:25 ` Joshua Crofts
2026-11-20 14:47 ` Greg Kroah-Hartman
2026-11-20 14:51 ` Joshua Crofts
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.