New: HCI_CHANNEL_USER sockets leave device running after exit
https://bugzilla.kernel.org/show_bug.cgi?id=214103
Bug ID: 214103
Summary: HCI_CHANNEL_USER sockets leave device running after
exit
Product: Drivers
Version: 2.5
Kernel Version: 5.11.0-7620-generic
Hardware: All
OS: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: Bluetooth
Assignee: [email protected]
Reporter: [email protected]
Regression: NoCreated attachment 298353
--> https://bugzilla.kernel.org/attachment.cgi?id=298353&action=edit
code to reproduce behavior
HCI_CHANNEL_USER is documented[1] as providing an exclusive (?[2]) Bluetooth socket channel for application use given CAP_NET_ADMIN. This channel type requires that the device be down when the socket is bound. The device transitions to UP RUNNING as a side-effect of a successful binding.
When the socket is closed and the application exits, the device remains up and running. It's unclear whether this is a bug or a feature; in any case it is not what somebody might expect, as it prevents the application from starting again without external action to bring the device back down.
Reproducing example attached, and command sequence below.
[2]: https://bugzilla.kernel.org/show_bug.cgi?id=135431
tirzah[1050]$ sudo hciconfig hci0 down
tirzah[1051]$ hciconfig hci0
hci0: Type: Primary Bus: USB
BD Address: A4:C3:F0:F2:23:E3 ACL MTU: 1021:4 SCO MTU: 96:6
DOWN
RX bytes:64500 acl:0 sco:0 events:4125 errors:0
TX bytes:650824 acl:0 sco:0 commands:3992 errors:0tirzah[1052]$ gcc repro.c
tirzah[1053]$ sudo setcap cap_net_raw,cap_net_admin=ep ./a.out tirzah[1054]$ getcap ./a.out
./a.out = cap_net_admin,cap_net_raw+ep
tirzah[1055]$ ./a.out
opening device 0
dd=3; binding to user channel
bound to user channel; closing
closed
tirzah[1056]$ hciconfig hci0
hci0: Type: Primary Bus: USB
BD Address: A4:C3:F0:F2:23:E3 ACL MTU: 1021:4 SCO MTU: 96:6
UP RUNNING
RX bytes:65256 acl:0 sco:0 events:4180 errors:0
TX bytes:653053 acl:0 sco:0 commands:4047 errors:0tirzah[1057]$
Signature · 4 lines
You may reply to this email to add a comment. You are receiving this mail because: You are the assignee for the bug.
[Bug 214103] HCI_CHANNEL_USER sockets leave device running after exit
https://bugzilla.kernel.org/show_bug.cgi?id=214103
Tedd An ([email protected]) changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]
--- Comment #1 from Tedd An ([email protected]) ---
If the Bluetooth daemon is running, try it after stop/disable the daemon.
If the bluetoothd is required, there is a "AutoEnable" option in /etc/bluetooth/main.conf. Change the value to false, and restart the daemon.
It will prevent the HCI interface from enabling after socket close.
Regards,
Tedd
Signature · 4 lines
You may reply to this email to add a comment. You are receiving this mail because: You are the assignee for the bug.