]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
xhci: Fix use-after-free in xhci_free_virt_device
authorMathias Nyman <mathias.nyman@linux.intel.com>
Thu, 3 May 2018 14:30:07 +0000 (17:30 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 14 Aug 2018 10:25:30 +0000 (12:25 +0200)
commita4b035a6fa29ac347857d9ca20df28d425a4e566
tree08b4741836299250c6d3009320154f8012cc9fe9
parentd518ec673c2b50bbe1fa3d5f57c36eb667af6e28
xhci: Fix use-after-free in xhci_free_virt_device

BugLink: http://bugs.launchpad.net/bugs/1778759
commit 44a182b9d17765514fa2b1cc911e4e65134eef93 upstream.

KASAN found a use-after-free in xhci_free_virt_device+0x33b/0x38e
where xhci_free_virt_device() sets slot id to 0 if udev exists:
if (dev->udev && dev->udev->slot_id)
dev->udev->slot_id = 0;

dev->udev will be true even if udev is freed because dev->udev is
not set to NULL.

set dev->udev pointer to NULL in xhci_free_dev()

The original patch went to stable so this fix needs to be applied
there as well.

Fixes: a400efe455f7 ("xhci: zero usb device slot_id member when disabling and freeing a xhci slot")
Cc: <stable@vger.kernel.org>
Reported-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/usb/host/xhci.c