mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] USB: EHCI: tegra: Fix use-after-free in .remove()
@ 2014-06-17 14:17 Tuomas Tynkkynen
  2014-06-17 14:26 ` Alan Stern
  2014-06-17 15:56 ` Stephen Warren
  0 siblings, 2 replies; 4+ messages in thread
From: Tuomas Tynkkynen @ 2014-06-17 14:17 UTC (permalink / raw)
  To: Alan Stern
  Cc: Greg Kroah-Hartman, linux-usb, linux-tegra, linux-kernel,
	Tuomas Tynkkynen

The tegra_ehci_hcd structure is located in the private space allocated
by the core USB code so it must not be accessed after the HCD is
freed.

Signed-off-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
---
 drivers/usb/host/ehci-tegra.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 6fdcb8a..5590567 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -479,10 +479,11 @@ static int tegra_ehci_remove(struct platform_device *pdev)
 
 	usb_phy_shutdown(hcd->phy);
 	usb_remove_hcd(hcd);
-	usb_put_hcd(hcd);
 
 	clk_disable_unprepare(tegra->clk);
 
+	usb_put_hcd(hcd);
+
 	return 0;
 }
 
-- 
1.8.1.5


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

* Re: [PATCH] USB: EHCI: tegra: Fix use-after-free in .remove()
  2014-06-17 14:17 [PATCH] USB: EHCI: tegra: Fix use-after-free in .remove() Tuomas Tynkkynen
@ 2014-06-17 14:26 ` Alan Stern
  2014-06-17 15:56 ` Stephen Warren
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Stern @ 2014-06-17 14:26 UTC (permalink / raw)
  To: Tuomas Tynkkynen; +Cc: Greg Kroah-Hartman, linux-usb, linux-tegra, linux-kernel

On Tue, 17 Jun 2014, Tuomas Tynkkynen wrote:

> The tegra_ehci_hcd structure is located in the private space allocated
> by the core USB code so it must not be accessed after the HCD is
> freed.
> 
> Signed-off-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
> ---
>  drivers/usb/host/ehci-tegra.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
> index 6fdcb8a..5590567 100644
> --- a/drivers/usb/host/ehci-tegra.c
> +++ b/drivers/usb/host/ehci-tegra.c
> @@ -479,10 +479,11 @@ static int tegra_ehci_remove(struct platform_device *pdev)
>  
>  	usb_phy_shutdown(hcd->phy);
>  	usb_remove_hcd(hcd);
> -	usb_put_hcd(hcd);
>  
>  	clk_disable_unprepare(tegra->clk);
>  
> +	usb_put_hcd(hcd);
> +
>  	return 0;
>  }

Acked-by: Alan Stern <stern@rowland.harvard.edu>


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

* Re: [PATCH] USB: EHCI: tegra: Fix use-after-free in .remove()
  2014-06-17 14:17 [PATCH] USB: EHCI: tegra: Fix use-after-free in .remove() Tuomas Tynkkynen
  2014-06-17 14:26 ` Alan Stern
@ 2014-06-17 15:56 ` Stephen Warren
  2014-06-17 19:30   ` Alan Stern
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Warren @ 2014-06-17 15:56 UTC (permalink / raw)
  To: Tuomas Tynkkynen, Alan Stern
  Cc: Greg Kroah-Hartman, linux-usb, linux-tegra, linux-kernel

On 06/17/2014 08:17 AM, Tuomas Tynkkynen wrote:
> The tegra_ehci_hcd structure is located in the private space allocated
> by the core USB code so it must not be accessed after the HCD is
> freed.

> diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c

This seems to be a persistent problem. Witness commit ecc8a0cdca18 "usb:
host: tegra: fix warning messages in ehci_remove". So, I wonder if ...

> @@ -479,10 +479,11 @@ static int tegra_ehci_remove(struct platform_device *pdev)
>  
>  	usb_phy_shutdown(hcd->phy);
>  	usb_remove_hcd(hcd);
> -	usb_put_hcd(hcd);
>  
>  	clk_disable_unprepare(tegra->clk);
>  

It's worth putting a comment here:

	/* This must be last, since *tegra is part of *hcd */
> +	usb_put_hcd(hcd);
> +
>  	return 0;
>  }

Of course, that could be a separate commit if you want.

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

* Re: [PATCH] USB: EHCI: tegra: Fix use-after-free in .remove()
  2014-06-17 15:56 ` Stephen Warren
@ 2014-06-17 19:30   ` Alan Stern
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Stern @ 2014-06-17 19:30 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Tuomas Tynkkynen, Greg Kroah-Hartman, linux-usb, linux-tegra,
	linux-kernel

On Tue, 17 Jun 2014, Stephen Warren wrote:

> On 06/17/2014 08:17 AM, Tuomas Tynkkynen wrote:
> > The tegra_ehci_hcd structure is located in the private space allocated
> > by the core USB code so it must not be accessed after the HCD is
> > freed.
> 
> > diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
> 
> This seems to be a persistent problem. Witness commit ecc8a0cdca18 "usb:
> host: tegra: fix warning messages in ehci_remove". So, I wonder if ...
> 
> > @@ -479,10 +479,11 @@ static int tegra_ehci_remove(struct platform_device *pdev)
> >  
> >  	usb_phy_shutdown(hcd->phy);
> >  	usb_remove_hcd(hcd);
> > -	usb_put_hcd(hcd);
> >  
> >  	clk_disable_unprepare(tegra->clk);
> >  
> 
> It's worth putting a comment here:
> 
> 	/* This must be last, since *tegra is part of *hcd */
> > +	usb_put_hcd(hcd);
> > +
> >  	return 0;
> >  }

Well, maybe.  At this stage it's not too likely that anything will be 
added after the usb_put_hcd().

> Of course, that could be a separate commit if you want.

This affects more than ehci-tegra.  The same concept applies to all the 
EHCI and OHCI platform drivers that use the platform-private area.

Alan Stern


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

end of thread, other threads:[~2014-06-17 19:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-17 14:17 [PATCH] USB: EHCI: tegra: Fix use-after-free in .remove() Tuomas Tynkkynen
2014-06-17 14:26 ` Alan Stern
2014-06-17 15:56 ` Stephen Warren
2014-06-17 19:30   ` Alan Stern

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

all inboxes | Powered by JetHome®