From owner-freebsd-usb@FreeBSD.ORG Sat Jan 3 23:02:57 2015 Return-Path: Delivered-To: freebsd-usb@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D22609BF for ; Sat, 3 Jan 2015 23:02:57 +0000 (UTC) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (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 9FAC12FC6 for ; Sat, 3 Jan 2015 23:02:57 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.9/8.14.9) with ESMTP id t03N2vRg050550 for ; Sat, 3 Jan 2015 23:02:57 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-usb@FreeBSD.org Subject: [Bug 196471] segmentation fault in libusb usage Date: Sat, 03 Jan 2015 23:02:57 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: usb X-Bugzilla-Version: 10.1-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: markus.heinz@uni-dortmund.de X-Bugzilla-Status: New X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-usb@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Jan 2015 23:02:57 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=196471 Bug ID: 196471 Summary: segmentation fault in libusb usage Product: Base System Version: 10.1-STABLE Hardware: i386 OS: Any Status: New Severity: Affects Only Me Priority: --- Component: usb Assignee: freebsd-usb@FreeBSD.org Reporter: markus.heinz@uni-dortmund.de Created attachment 151308 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=151308&action=edit testcase for libusb segmentation fault I have encountered a segmentation fault when using libusb on an i386 FreeBSD 10.1 system with the latest patches applied: Steps to reproduce: - get a pointer libusb_device *device - use it in some way - close it - reopen it - claim an interface of the device handle - then it crashes with a segmentation fault Debugging the libusb_claim_interface method led to this observation: I am referring to this source code: http://svnweb.freebsd.org/base/stable/10/lib/libusb/libusb10.c?view=markup#l611 In line 615 the libusb_device * is calculated from the given libusb_device_handle *. The device does contain a NULL pointer as dev->ctx. This null pointer is passed to CTX_LOCK in line 622. Then the segmentation fault occurs. If this line is inserted before line 622 the segmentation fault does not occur: dev->ctx = GET_CONTEXT(dev->ctx); But I am not sure if this is the right way to address the problem. I have created a testcase which I will attach. You need to replace the manufacturer and product ids with some values for a connected usb device. The values in the example are for a HP Deskjet 5550 printer. The same testcase works as expected on an Ubuntu 14.04 system with libusbx 1.0.17. -- You are receiving this mail because: You are the assignee for the bug.