Bug 247588

Summary: Bluetooth HCI unprivileged socket has no LE access
Product: Base System Reporter: Val Packett <val>
Component: kernAssignee: Takanori Watanabe <takawata>
Status: Closed FIXED    
Severity: Affects Only Me CC: emax, lwhsu, takawata
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Val Packett 2020-06-27 13:31:29 UTC
Scanning for Bluetooth Low Energy (BLE) beacons currently requires root access, which is ehhhh not great.

From a quick look at the code, looks like setting some bits for allowing LE commands/events was intended, but no bits are set:

https://github.com/freebsd/freebsd/blob/6266cce175c89b44f06d967f99d32f9a7d16f461/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c#L882-L883

OCF_LE_SET_SCAN_PARAMETERS and OCF_LE_SET_SCAN_ENABLE should definitely be accessible.. and at least 0x3e (LE meta) events should be readable, I don't see what in the code would block them but I haven't got them as non-root.

Also, maybe all of this should be controllable via sysctls.
Comment 1 Takanori Watanabe freebsd_committer freebsd_triage 2020-06-30 04:28:35 UTC
Please try this patch.

https://reviews.freebsd.org/D25516
Comment 2 commit-hook freebsd_committer freebsd_triage 2020-07-01 04:00:59 UTC
A commit references this bug:

Author: takawata
Date: Wed Jul  1 04:00:55 UTC 2020
New revision: 362825
URL: https://svnweb.freebsd.org/changeset/base/362825

Log:
  Allow some Bluetooth LE related HCI request to non-root user.

  PR:	247588
  Reported by:	Greg V (greg@unrelenting.technology)
  Reviewed by:	emax
  Differential Revision:	https://reviews.freebsd.org/D25516

Changes:
  head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c