From nobody Tue Dec 9 09:48:16 2025 X-Original-To: usb@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4dQYv45cM5z6KJkm for ; Tue, 09 Dec 2025 09:48:16 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dQYv44zyTz3LCw for ; Tue, 09 Dec 2025 09:48:16 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765273696; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zHUo2zcPL15Mk8u7M7iKP46lYaqwfYpwURHDxbsQZqM=; b=Rpt5KmMVFT0p8boivQJdJnEXTpwLoZlaz0rjADMZ2vHZPqa7boBsYNZvjaZ1Kd2m6yI1Fn tuW7NlkMCqzeuB/v9cwf/7udPj9hzu6ghHsz6VD7305KKwm3FsFPl2BpbSo/qtXEtGfX/a OZv54AN8xulkVAjl/xwam5ORnHoKlHR2nsnbW5UK6NpKsH+cFeDhugq0VADzurwV+wF2QG oXt+XmTEeKvG4GtI+VM9QskynNVafvwx4c4BSFG8DeChQCDh0sQElf+06pWyIfYfLZ8k8S zCfy3Sps314XAIBh9YQsQMSkvaJuyausCQknDNRNr2TOnC7VNHll7wFiDCuAsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765273696; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zHUo2zcPL15Mk8u7M7iKP46lYaqwfYpwURHDxbsQZqM=; b=vgBWfw+8GU62OOYmhm4wmALYM22wgHIW1zcUX6xZRCwkW8XtZiHotz1/VxdD/G2FQy8Zxl 6K60bBoSZnjhbqE2q1Y0jqQZn1+KjZKAV2RBwqVBgQxiDb8HGL6OPAG1HFiDqfE/wh6hgL sZX1kloiwf9KTW6l5bxlZflXPuNZSsD/dctyBmBJ5y/+kIHStvYx9MddBPEHV6BrXb5tu1 3RIpQYdqGauXNiMAaQ9mR9oMcdu78SwkYuikztRZ8rsRuQgcxq/NTGPJXImVG/qrSFJMJr smznBNKt7VdkUfVKVHIjsenUzz6ej73SQt+IumEDmb5eLMDtdjbbHxnnqp9j6Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1765273696; a=rsa-sha256; cv=none; b=ixIdezrHQy1D3adCMGQsJXq5yipnPmvJPb/GZvV42U8cnH2sfTs1vc9U1P7fbnPP2F+8QP ML49R5ySuSYQghnEWMQI61+gkMa9xJyOiAELYynQog18iJc9wulckE024fD7Q7T4QkYg9I N66q6P/uh+njubYgn9yvWTzJOs/2Jceb20nGEzCakrZEXEnPNfixrx5x8kRxZBUWfEEw6N zMFwI2ULbZcW7rkeC0fWyKkqEKTGfIfgOjhTTKfUYVnRyfI+qZEfB2jB4wSZADi30JSp8d dcAXJ9A4MYp/w0GkSR02ke2hU5EpwSHDP1oI3cQ3pBTL+Q4TW8VHUtuCA9RkaQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4dQYv44G3fztC5 for ; Tue, 09 Dec 2025 09:48:16 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 5B99mG27019625 for ; Tue, 9 Dec 2025 09:48:16 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 5B99mGUu019624 for usb@FreeBSD.org; Tue, 9 Dec 2025 09:48:16 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: usb@FreeBSD.org Subject: [Bug 291506] libusb_open advisory lock (libusb compatiblity) Date: Tue, 09 Dec 2025 09:48:16 +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: 15.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: unitrunker@unitrunker.net X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: usb@FreeBSD.org 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-usb List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: freebsd-usb@freebsd.org Sender: owner-freebsd-usb@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D291506 Bug ID: 291506 Summary: libusb_open advisory lock (libusb compatiblity) Product: Base System Version: 15.0-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: usb Assignee: usb@FreeBSD.org Reporter: unitrunker@unitrunker.net Created attachment 266026 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D266026&action= =3Dedit Proposed patch Summary To more closely match behavior of libusb_open on other platforms, place an advisory lock on the device file descriptor. Currently, multiple processes can open the same USB device. On Linux and Windows, USB device enumeration omits devices currently in use. A number of ports assume this behavior. This proposed change will cause libusb_open to report an error (LIBUSB_ERROR_ACCESS) if it finds an advisory lock on the device. This includes a further change to libusb_open_with_vid_pid to skip over fai= led attempts to the first successful call to libusb_open. In an exteme case, this unexpected behavior in the FreeBSD implementation causes two ports to display the same device 32 times (see ports airspy and hydrasdr). As an example, a FreeBSD host has two USB devices attached that share the s= ame VID/PID but different serial numbers. The intent is ... a. a first call to libusb_open_with_vid_pid returns a device handle to the first matching device - which the app keeps open. b. a second call to libusb_open_with_vid_pid returns a device handle to the second matching device (and not the first) - which the app keeps open. c. a third call to libusb_open_with_vid_pid returns null (and none of the o= ther devices). libusb_close or process exit remove the advisory lock on the device. The specific advisory lock mechanism is flock(2). A complete patch is included.= I will follow up with a test plan and the bits of code used for testing. --=20 You are receiving this mail because: You are the assignee for the bug.=