linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Schmid, Carsten" <Carsten_Schmid@mentor.com>
To: Hans de Goede <hdegoede@redhat.com>,
	Mathias Nyman <mathias.nyman@linux.intel.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: AW: [Resend] [PATCH v3] usb: xhci-pci: reorder removal to avoid use-after-free
Date: Thu, 22 Aug 2019 15:48:11 +0000	[thread overview]
Message-ID: <0012c7c76be947f68e30eb687599bed3@SVR-IES-MBX-03.mgc.mentorg.com> (raw)
In-Reply-To: <6d245699-b7d6-2b40-62df-366c88cba7dc@redhat.com>

> On 22-08-19 17:23, Mathias Nyman wrote:
> > On 16.8.2019 12.03, Schmid, Carsten wrote:
> >> On driver removal, the platform_device_unregister call
> >> attached through devm_add_action_or_reset was executed
> >> after usb_hcd_pci_remove.
> >> This lead to a use-after-free for the iomem resource of
> >> the xhci-ext-caps driver in the platform removal
> >> because the parent of the resource was freed earlier.
> >>
> >> Fix this by reordering of the removal sequence.
> >>
> >
> > Could all this be avoided if usb_hcd_pci_probe()
> > used managed device resources as well?
> > (using devm_request_mem_region(), and devm_ioremap_nocache())
> >
> > This way the iomem resource would be added to the same devres list
> > as the platform_unregister_call, and the iomem resource should be
> > released after the platform_device_unregister as devres_release_all()
> > releases the resources in reverse order.
> 
> Yes I believe that that would work.
> 
I don't think so, because xhci_create_intel_xhci_sw_pdev registers it's 
resource through platform_device_add_resources which does not use devm_.

The only thing what is done through devm in xhci_create_intel_xhci_sw_pdev is
ret = devm_add_action_or_reset(...)

Carsten

  reply	other threads:[~2019-08-22 15:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-16  9:03 [Resend] [PATCH v3] usb: xhci-pci: reorder removal to avoid use-after-free Schmid, Carsten
2019-08-22 15:23 ` Mathias Nyman
2019-08-22 15:25   ` Hans de Goede
2019-08-22 15:48     ` Schmid, Carsten [this message]
2019-08-22 20:14       ` AW: " Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0012c7c76be947f68e30eb687599bed3@SVR-IES-MBX-03.mgc.mentorg.com \
    --to=carsten_schmid@mentor.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).