Skip to contentSkip to conversation

patch "xhci: Fix use-after-free in xhci_free_virt_device" added to usb-linus

PATCH [email protected] 1 participant 1 message May 3, 2018

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

xhci: Fix use-after-free in xhci_free_virt_device

to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

Quoted 1 line

From 44a182b9d17765514fa2b1cc911e4e65134eef93 Mon Sep 17 00:00:00 2001

From: Mathias Nyman <[email protected]>
Date: Thu, 3 May 2018 17:30:07 +0300
Subject: xhci: Fix use-after-free in xhci_free_virt_device

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")
---
 drivers/usb/host/xhci.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/host/xhci.c +1 -0
index 9b27798ecce5..711da3306b14 100644
@@ -3621,6 +3621,7 @@ static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
 		del_timer_sync(&virt_dev->eps[i].stop_cmd_timer);
 	}
 	xhci_debugfs_remove_slot(xhci, udev->slot_id);
+	virt_dev->udev = NULL;
 	ret = xhci_disable_slot(xhci, udev->slot_id);
 	if (ret)
 		xhci_free_virt_device(xhci, udev->slot_id);
Signature · 1 line
2.17.0