linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Mathias Nyman <mathias.nyman@linux.intel.com>,
	"Schmid, Carsten" <Carsten_Schmid@mentor.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: [Resend] [PATCH v3] usb: xhci-pci: reorder removal to avoid use-after-free
Date: Thu, 22 Aug 2019 17:25:04 +0200	[thread overview]
Message-ID: <6d245699-b7d6-2b40-62df-366c88cba7dc@redhat.com> (raw)
In-Reply-To: <fbbf1ed3-c0c0-9b34-aeec-32a6f3645d7b@linux.intel.com>

Hi,

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.

Regards,

Hans


  reply	other threads:[~2019-08-22 15:25 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 [this message]
2019-08-22 15:48     ` AW: " Schmid, Carsten
2019-08-22 20:14       ` 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=6d245699-b7d6-2b40-62df-366c88cba7dc@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=Carsten_Schmid@mentor.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).