Date: Fri, 3 Jul 2020 10:10:23 +0200 From: Hans Petter Selasky <hps@selasky.org> To: Jan Behrens <jbe-mlist@magnetkern.de> Cc: "freebsd-usb@FreeBSD.org" <freebsd-usb@freebsd.org> Subject: Re: USB reset fails when using a LimeSDR Mini on FreeBSD Message-ID: <4fdcdc92-6a0d-5645-0a10-e95d69001d3a@selasky.org> In-Reply-To: <20200703095108.7ce5497f53ed4c4a3d7289e3@magnetkern.de> References: <20200625121052.e9f7e7cbeb68fad264ec80a9@magnetkern.de> <20200627144419.f14371695d9b62ea99106c4a@magnetkern.de> <CAM8r67DTKdj0%2BhkOegjBj-ywzWFq2CnS2sQed0mibSUeGp6HSQ@mail.gmail.com> <20200627173604.7f7b7777140e66dbad812fc7@magnetkern.de> <CAM8r67DqZzje=JnrT_R3d6Uo_NxjvGsvpydd1NOTrJHU2jHzQA@mail.gmail.com> <20200627180420.4b8012fb@ernst.home> <20200702103523.adb0566bcc7b6e354905a8a5@magnetkern.de> <97c8fd11-9200-dff7-4c68-b0b80cc44871@selasky.org> <20200702104743.223e98c325806025704703f2@magnetkern.de> <e3bd0417-c89c-5598-448e-33ec1e505a3f@selasky.org> <20200702111538.e7edf0ae8d10ec7ede9acebb@magnetkern.de> <9e14575a-5c8b-28c8-6593-22019a21e7e7@selasky.org> <20200702120655.73d1111e2de81c626be78139@magnetkern.de> <8ac365f3-3d33-4730-622e-e66f29dd5938@selasky.org> <20200702123747.1bdf36b9d2ebe283f7bb855e@magnetkern.de> <a6077d0e-71d6-4067-2651-428ce175b33b@selasky.org> <20200703095108.7ce5497f53ed4c4a3d7289e3@magnetkern.de>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Jan, On 2020-07-03 09:51, Jan Behrens wrote: >> >> Yes, and we have one or two firmware loading utilities in base still >> using them. > > Except that /dev/usb/X.Y.0 (which is linked by /dev/ugenX.Y) controls > access rights to the device through libusb, right? Yes, that is correct. >> >> Yes, but opening /dev/ugenX.Y doesn't mean that kernel device drivers >> are detached from this device. > > Can/does a kernel device driver restrict what a user can do with the > device when the kernel driver is active? Or does access to the device > always enable a user to mess up things badly? The kernel device driver can not restrict what the user-space driver can do. Yes, user-space can mess up the device totally. >> >> User-space drivers are requested to create a uniq PID file, to avoid >> clashes with multiple drivers on the same interface and may use >> libusb_claim_interface() to tell the kernel to detach any drivers on >> that specific interface. > > If the kernel refuses to give up control, is the user-space program > denied access? If yes, I can generally understand why you don't want a > USB reset to be initiated by a user-space program (at least as long > there are kernel drivers attached). The FreeBSD USB stack has no concept of exclusive access to USB endpoints. Simply if both kernel and user-space attach to the same device, user-space will receive half of the USB packets and the kernel the other half. >> If you for example load the LimeSDR two times for the same ugenX.Y >> device, then the interface communication might stop working, even though >> no error is reported. > > Thus the lock of user-space drivers is only advisory and not enforced? Right, it is not enforced. > How about if a kernel driver uses the device? Can/does the kernel block > out a user-space driver that would mess with the kernel's operation on > the device? No, it is all transparent. Kernel drivers cannot block user-space, but user-space can detach kernel-space. That's all. > > I see three possible approaches currently: > > 1. Allowing a USB reset if the user has access to /dev/ugenX.Y (might > allow users to mess with kernel's operation on a device, unless the > problem exists anyway, see my questions above). > > 2. Allowing a USB reset if the user has access to /dev/ugenX.Y and > there are other prerequirements fulfilled (e.g. a sysctl setting to > enable it globally, which might not be fine-graded enough, or the > requirement that there is currently no kernel driver attached, or a > combination thereof). > > 3. Providing a way to grant "reset permissions" on a per-device basis > (might be overkill, and not really needed). > Maybe you're right we should allow this for non-root aswell. I need to think about it! --HPS
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4fdcdc92-6a0d-5645-0a10-e95d69001d3a>