diff options
author | hselasky <hselasky@FreeBSD.org> | 2015-08-29 06:11:50 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2015-08-29 06:11:50 +0000 |
commit | 6323991c32b50145b2410f193aa0685e74466053 (patch) | |
tree | b7513c6af1748f611077171dd75c2e98f5d02b87 /sys/dev | |
parent | 10823346a0096906e1c338f89ef960c36b5eae01 (diff) | |
download | FreeBSD-src-6323991c32b50145b2410f193aa0685e74466053.zip FreeBSD-src-6323991c32b50145b2410f193aa0685e74466053.tar.gz |
MFC r286799:
Fix race in USB PF which can happen if we stop tracing exactly when
the kernel is tapping an USB transfer. This leads to a NULL pointer
access. The solution is to only trace while the USB bus lock is
locked.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/usb_pf.c | 6 | ||||
-rw-r--r-- | sys/dev/usb/usb_transfer.c | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/sys/dev/usb/usb_pf.c b/sys/dev/usb/usb_pf.c index 27ab5f7..8c47e79 100644 --- a/sys/dev/usb/usb_pf.c +++ b/sys/dev/usb/usb_pf.c @@ -220,7 +220,13 @@ usbpf_clone_destroy(struct if_clone *ifc, struct ifnet *ifp) ubus = ifp->if_softc; unit = ifp->if_dunit; + /* + * Lock USB before clearing the "ifp" pointer, to avoid + * clearing the pointer in the middle of a TAP operation: + */ + USB_BUS_LOCK(ubus); ubus->ifp = NULL; + USB_BUS_UNLOCK(ubus); bpfdetach(ifp); if_detach(ifp); if_free(ifp); diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c index c5815f7..6c2e1440 100644 --- a/sys/dev/usb/usb_transfer.c +++ b/sys/dev/usb/usb_transfer.c @@ -2381,8 +2381,11 @@ usbd_callback_wrapper(struct usb_xfer_queue *pq) } #if USB_HAVE_PF - if (xfer->usb_state != USB_ST_SETUP) + if (xfer->usb_state != USB_ST_SETUP) { + USB_BUS_LOCK(info->bus); usbpf_xfertap(xfer, USBPF_XFERTAP_DONE); + USB_BUS_UNLOCK(info->bus); + } #endif /* call processing routine */ (xfer->callback) (xfer, xfer->error); |