Bug 247588 - Bluetooth HCI unprivileged socket has no LE access
Summary: Bluetooth HCI unprivileged socket has no LE access
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Takanori Watanabe
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-27 13:31 UTC by Greg V
Modified: 2020-07-01 04:01 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Greg V 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 2020-06-30 04:28:35 UTC
Please try this patch.

https://reviews.freebsd.org/D25516
Comment 2 commit-hook freebsd_committer 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