Search code examples
macosbluetoothiokitkernel-extension

Don't know why my OS X kext with a lower probe score is being matched


I am trying to selectively screen and disable certain USB devices. For that purpose I have written an IOUSBInterface driver that specifies wildcards for idProduct, idVendor, and bcdDevice. Anytime I do not want to disable a given device, I set probeScore to 0 and return.

The probeScore approach works in almost all cases, and I can see my driver considering each USB device in turn in system.log. But in the case of the Bluetooth USB Host Controller, the kernel attaches my driver to it despite my probe score of 0. By comparison, if my driver is not present, the Bluetooth USB Host Controller matches with a probe score of 90,000.

It is true that my driver specifies OSBundleRequired as Root, but the Bluetooth USB Host Controller specifies OSBundleRequired as Safe Boot, which would seem to put them on the same footing. On the other hand I'm having the same Yosemite Bluetooth problems as others, and my Bluetooth mouse doesn't respond until after I login, suggesting that the Bluetooth USB Host Controller might not be getting loaded until after boot time.


Solution

  • Completely rewritten answer as I'd misunderstood the question

    First off, from the horse's mouth:

    "Note that you should never add your own IOProbeScore property to a USB driver's property list."

    That's probably why you're not having much joy with the probe score. (Note that the above recommendation only applies to USB devices; disregard for Thunderbolt etc.)

    If modifying your personality matching dictionary to not match the device in question isn't practical (it sounds like you want to decide at runtime, so that's a good reason) then override your driver's probe() method and selectively return this or NULL from it depending on whether you want your (blocker) driver to claim the device or not. Returning NULL from probe() should always work - if it's causing trouble, you most likely have a bug in your code somewhere.