]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
usb: Avoid use-after-free by flushing endpoints early in usb_set_interface()
authorMathias Nyman <mathias.nyman@linux.intel.com>
Mon, 3 Sep 2018 12:44:16 +0000 (15:44 +0300)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:48:58 +0000 (19:48 -0600)
commit253defba38bfaae5d1c850e62c1950975c673009
treef763b6a6523b6efca3115125c78c98701f1eda3e
parent43c36c75fdb3987213d81d91e93a0a124b12591f
usb: Avoid use-after-free by flushing endpoints early in usb_set_interface()

BugLink: https://bugs.launchpad.net/bugs/1836117
commit f9a5b4f58b280c1d26255376713c132f93837621 upstream.

The steps taken by usb core to set a new interface is very different from
what is done on the xHC host side.

xHC hardware will do everything in one go. One command is used to set up
new endpoints, free old endpoints, check bandwidth, and run the new
endpoints.

All this is done by xHC when usb core asks the hcd to check for
available bandwidth. At this point usb core has not yet flushed the old
endpoints, which will cause use-after-free issues in xhci driver as
queued URBs are cancelled on a re-allocated endpoint.

To resolve this add a call to usb_disable_interface() which will flush
the endpoints before calling usb_hcd_alloc_bandwidth()

Additional checks in xhci driver will also be implemented to gracefully
handle stale URB cancel on freed and re-allocated endpoints

Cc: <stable@vger.kernel.org>
Reported-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/usb/core/message.c