From owner-svn-src-all@freebsd.org Sat Aug 29 06:17:40 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DEB519C4BF5; Sat, 29 Aug 2015 06:17:40 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CBD4D18DD; Sat, 29 Aug 2015 06:17:40 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7T6HeIB029307; Sat, 29 Aug 2015 06:17:40 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7T6HeXG029304; Sat, 29 Aug 2015 06:17:40 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201508290617.t7T6HeXG029304@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Sat, 29 Aug 2015 06:17:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r287273 - stable/9/sys/dev/usb X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2015 06:17:41 -0000 Author: hselasky Date: Sat Aug 29 06:17:39 2015 New Revision: 287273 URL: https://svnweb.freebsd.org/changeset/base/287273 Log: 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. Modified: stable/9/sys/dev/usb/usb_pf.c stable/9/sys/dev/usb/usb_transfer.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/usb_pf.c ============================================================================== --- stable/9/sys/dev/usb/usb_pf.c Sat Aug 29 06:11:50 2015 (r287272) +++ stable/9/sys/dev/usb/usb_pf.c Sat Aug 29 06:17:39 2015 (r287273) @@ -103,13 +103,16 @@ usbpf_detach(struct usb_bus *ubus) { struct ifnet *ifp = ubus->ifp; + USB_BUS_LOCK(ubus); + ubus->ifp = NULL; + USB_BUS_UNLOCK(ubus); + if (ifp != NULL) { bpfdetach(ifp); if_down(ifp); if_detach(ifp); if_free(ifp); } - ubus->ifp = NULL; } static uint32_t Modified: stable/9/sys/dev/usb/usb_transfer.c ============================================================================== --- stable/9/sys/dev/usb/usb_transfer.c Sat Aug 29 06:11:50 2015 (r287272) +++ stable/9/sys/dev/usb/usb_transfer.c Sat Aug 29 06:17:39 2015 (r287273) @@ -2292,8 +2292,11 @@ usbd_callback_wrapper(struct usb_xfer_qu } #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);