On 2024-02-19, Kirill A Korinsky <kir...@korins.ky> wrote: > On Mon, 19 Feb 2024 23:09:35 +0100, > Stuart Henderson wrote: >> >> > I read that as it is impossible to blacklist a device, right? >> >> Only by running a kernel where the driver's attach routine has been >> modified to skip attaching the device e.g. if it matches certain >> vendor/device id. OpenBSD doesn't have any other way to detach a USB >> driver from a device. >> > > As an alternative solution, is it possible to enforce ugen to specific > device by vendor and product IDs? > > I've tried: > > $ doas config -e -o /bsd.new /bsd > ukc> find ugen > 309 ugen* at uhub*|uhub* port -1 configuration -1 interface -1 vendor -1 > product -1 release -1 flags 0x0 > ukc> find uaudio > 303 uaudio* at uhub*|uhub* port -1 configuration -1 interface -1 vendor -1 > product -1 release -1 flags 0x0 > ukc> add ugen > Device not complete number or * is missing > ukc> add ugen* > Clone Device (DevNo, 'q' or '?') ? 309 > Insert before Device (DevNo, 'q' or '?') ? 303 > 303 ugen* at uhub*|uhub* port -1 configuration -1 interface -1 vendor -1 > product -1 release -1 flags 0x0 > ukc> change 303 > 303 ugen* at uhub*|uhub* port -1 configuration -1 interface -1 vendor -1 > product -1 release -1 flags 0x0 > change [n] y > port [-1] ? > configuration [-1] ? > interface [-1] ? > vendor [-1] ? 0x041e > product [-1] ? 0x3130 > release [-1] ? > flags [0] ? > 303 ugen* changed > 303 ugen* at uhub*|uhub* port -1 configuration -1 interface -1 vendor 0x41e > product 0x3130 release -1 flags 0x0 > ukc> find ugen* > 303 ugen* at uhub*|uhub* disable port -1 configuration -1 interface -1 > vendor 0x41e product 0x3130 release -1 flags 0x0 > 310 ugen* at uhub*|uhub* port -1 configuration -1 interface -1 vendor -1 > product -1 release -1 flags 0x0 > ukc> quit > Saving modified kernel. > > with no luck. >
No - ugen acts as a fallback. If a USB device is claimed by another driver, ugen won't get a chance to attach to it. There is a common mechanism to recognise devices by vid/pid for special handling - sometimes to prevent attaching - sometimes for other adaptations which are needed. If you're interested, see sys/dev/usb/usb_quirks.c and look at how UQ_BAD_HID is used to knock out devices which would normally be claimed by uhid(4); you could use something similar to prevent e.g. uaudio from attaching to a certain device. However, it would require compiling the kernel to configure it.