Commit Graph

26170 Commits

Author SHA1 Message Date
Marcel Holtmann
5ddd8cd51c monitor: Remove unneeded fprintf for new devices 2021-08-03 21:55:00 +02:00
Marcel Holtmann
f9b8fac243 monitor: Count number of control messages 2021-08-03 17:04:47 +02:00
Marcel Holtmann
30a4fdcbfe monitor: Add ISO packets to analyze option 2021-08-03 16:58:41 +02:00
Marcel Holtmann
f722367376 monitor: Remove unneeded fprintf for unknown opcodes 2021-08-03 16:54:03 +02:00
Yun-Hao Chung
6bbb22a096 gatt-db: remove redundant check in foreach range
svc_start < foreach_data->end has already been checked in a few lines
before.

Reviewed-by: Archie Pusaka <apusaka@chromium.org>
2021-07-29 14:46:17 -07:00
Luiz Augusto von Dentz
9cd5c344f3 main.conf: Revert default for Privacy and Experimental
Privacy shall be off by default until kernel is stable to support it,
also Experimental shall only be enabled for testing purpose.
2021-07-29 14:09:17 -07:00
Sonny Sasaka
8e53124d49 monitor: Print EIR of Extended Advertisement Report
It's useful to be able to see Extended Adv's EIR flags just like the
legacy Adv.
2021-07-29 13:55:19 -07:00
Luiz Augusto von Dentz
ba8a23d4af gatt: Add support for Central Address Resolution characteristic
This adds Central Address Resolution characteristic so peripherals can
use directed advertising using RPA as initiator address.
2021-07-28 13:44:44 -07:00
Luiz Augusto von Dentz
b497b5942a adapter: Fix storing discoverable setting
discoverable setting shall only be store when changed via Discoverable
property and not when discovery client set it as that be considered
temporary just for the lifetime of the discovery.
2021-07-26 09:30:06 -07:00
Hannu Mallat
bb27e5e1be obexd: phonebook: Set default apparams for PTS clients
Some PTS clients do not send all the mandatory apparams
when retrieving the phonebook. Clients such as car multimedia systems
cannot be fixed, therefore working around this issue by inserting
default apparams which makes these clients work as well.
2021-07-23 14:47:37 -07:00
Dylan Van Assche
edb86e5e01 configure.ac: add libebook dependency
Require libebook when phonebook-ebook plugin is built.
2021-07-23 14:47:37 -07:00
Juho Hamalainen
b1c73f4d4c configure.ac: specify phonebook plugin at build time
Various phonebook plugins are available, by default
phonebook-dummy is always built. Allow to specify
which plugin to use at build time.
2021-07-23 14:47:37 -07:00
Dylan Van Assche
bdeaad3fa0 obexd: phonebook-ebook: modernize
Modernize PBAP phonebook-ebook plugin for newer libebook version
of the Evolution Data Server.

The ebook plugin was introduced during GSoC 2011 [1] and allows
BlueZ to share contacts stored in the Evolution Data Server to
connected clients such as car multimedia systems.
With the rise of Mobile Linux thanks to the PinePhone and Librem 5,
this plugin was modernized to compile with newer libebook versions
because the API was changed [2].

[1] http://www.bluez.org/gsoc-eds-backend-of-phonebook-access-profilepbap/
[2] https://wiki.gnome.org/Apps/Evolution/ESourceMigrationGuide
2021-07-23 14:47:37 -07:00
Joseph Hwang
e0ea1c9c0d tools: btmgmt: support quality experiment feature command
This patch adds the "exp-quality" command to btmgmt to enable/disable
the Bluetooth quality report.
2021-07-20 11:05:05 -07:00
Joseph Hwang
7be40ec843 adapter: read quality report feature
This patch adds a new UUID for the quality report experimental
feature. When reading the experimental features, it checks if
the new feature is supported by the controller and stores the
value in the quality_report_supported flag of the adapter.

The quality_report_supported flag could be used by the bluetoothd
to determine if the quality report feature can be enabled.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
2021-07-20 10:59:05 -07:00
Joseph Hwang
de6c0c77e5 monitor: add new Intel extended telemetry events
This patch adds new Intel extended telemetry events for both ACL and
SCO/eSCO audio link quality reports.

For SCO/eSCO audio link quality report, it shows something like
> HCI Event: Vendor (0xff) plen 190  #120 [hci0] 2021-05-31 20:27:50.257
        Vendor Prefix (0x8780)
      Intel Extended Telemetry (0x87)
        Extended Telemetry (0x80): SubOpcode (0x03)
        Extended event type (0x01): Audio Link Quality Report Type(0x05)
        SCO/eSCO connection handle (0x6a): 0x0101
        Packets from host (0x6b): 399
        Tx packets (0x6c): 403
        Rx payload lost (0x6d): 3
        Tx payload lost (0x6e): 0
        Rx No SYNC errors (0x6f): 3 2 3 3 0
        Rx HEC errors (0x70): 0 0 0 0 0
        Rx CRC errors (0x71): 2 0 0 0 0
        Rx NAK errors (0x72): 6 0 0 0 0
        Failed Tx due to Wifi coex (0x73): 6 0 0 0 0
        Failed Rx due to Wifi coex (0x74): 0 0 0 0 0
        Late samples inserted based on CDC (0x75): 0
        Samples dropped (0x76): 0
        Mute samples sent at initial connection (0x77): 0
        PLC injection data (0x78): 0

For ACL audio link quality report, it shows something like
> HCI Event: Vendor (0xff) plen 142  #120 [hci0] 2021-05-31 20:27:50.261
        Vendor Prefix (0x8780)
      Intel Extended Telemetry (0x87)
        Extended Telemetry (0x80): SubOpcode (0x03)
        Extended event type (0x01): Audio Link Quality Report Type(0x05)
        ACL connection handle (0x4a): 0x0100
        Rx HEC errors (0x4b): 0
        Rx CRC errors (0x4c): 0
        Packets from host (0x4d): 100
        Tx packets (0x4e): 101
        Tx packets 0 retries (0x4f): 89
        Tx packets 1 retries (0x50): 11
        Tx packets 2 retries (0x51): 1
        Tx packets 3 retries (0x52): 0
        Tx packets 4 retries and more (0x53): 0
        Tx DH1 packets (0x54): 0
        Tx DH3 packets (0x55): 0
        Tx DH5 packets (0x56): 0
        Tx 2DH1 packets (0x57): 0
        Tx 2DH3 packets (0x58): 0
        Tx 2DH5 packets (0x59): 0
        Tx 3DH1 packets (0x5a): 6
        Tx 3DH3 packets (0x5b): 0
        Tx 3DH5 packets (0x5c): 94
        Rx packets (0x5d): 272
        ACL link throughput (KBps) (0x5e): 343815
        ACL max packet latency (ms) (0x5f): 20625
        ACL avg packet latency (ms) (0x60): 12

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
2021-07-20 10:59:05 -07:00
Yun-Hao Chung
cb53d86be6 core: fix a possible crash when removing devices
In probe_service, if the service already exists in device->services, it
returns the service. This might cause dev_probe and device_probe_profile
to add a duplicate service into device->services. When removing the
device, a double-free error might occur.

This patch changes the logic of probe_service so that the same service
will not be added to a device.
2021-07-20 08:49:04 -07:00
Luiz Augusto von Dentz
0f849abb1b btdev: Fix not checking conditions for LE Set Random Address
The spec says LE Set Random Address cannot be used when scan is enabled
or with legacy advertising:

BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 4, Part E
page 2480

  'If the Host issues this command when any of advertising (created
  using legacy advertising commands), scanning, or initiating are
  enabled, the Controller shall return the error code Command
  Disallowed (0x0C).'
2021-07-19 14:16:16 -07:00
Luiz Augusto von Dentz
0356d2a4c6 btdev: Add proper checks for own_addr_type for LE scan/adv
own_addr_type 0x01 and 0x03 shall check that a random address has
properly been set:

BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 4, Part E
page 2496:

  'If LE_Scan_Enable is set to 0x01, the scanning parameters'
  Own_Address_Type parameter is set to 0x01 or 0x03, and the random
  ddress for the device has not been initialized, the Controller shall
  return the error code Invalid HCI Command Parameters (0x12).'

BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 4, Part E
page 2614:

  'If Enable is set to 0x01, the scanning parameters' Own_Address_Type
  parameter is set to 0x01 or 0x03, and the random address for the
  device has not been initialized, the Controller shall return the
  error code Invalid HCI Command Parameters (0x12).'
2021-07-19 14:15:47 -07:00
Brian Gix
daea569566 tool/mgmt-tester: Add fail_tolerant exception
Race conditions with the cmd-sync changes can cause fail status codes to
be different than originally expected. New test parameter fail_tolerant
allows a trivial fail-code mismatches to "Pass" while also warning that
the status wasn't exactly as expected.
2021-07-16 12:36:02 -07:00
Brian Gix
41bf62e089 tool/mgmt-tester: Add test cases for Read Clock Information API
This patch adds test cases for Read Clock Information management API.
2021-07-16 12:35:14 -07:00
Tedd Ho-Jeong An
14c6a73265 emulator/btdev: Add support HCI_READ_CLOCK command
This patch adds support HCI_READ_CLOCK command in btdev.
2021-07-16 12:24:58 -07:00
Yun-Hao Chung
16395e11db a2dp: Fix crash in channel_free while waiting cmd resp
When channel_free is called and we are waiting for a command response
from the peer, bluez NULL the setup->session but would not free its
setup_cb. Since setup_cb holds a ref of setup, the setup wouldn't be
freed and if service_removed is called after channel_free, a2dp_cancel
tries to abort the ongoing avdtp commands, which accesses the
setup->session and triggers a crash.

This change finalizes all avdtp commands before assigning setup->session
to NULL in channel_free.

Crash stack trace:
0x000059f01943e688	(bluetoothd -avdtp.c:3690)
avdtp_abort
0x000059f01943928a	(bluetoothd -a2dp.c:3069)
a2dp_cancel
0x000059f0194377fa	(bluetoothd -sink.c:324)
sink_unregister
0x000059f01948715a	(bluetoothd -service.c:177)
service_remove
0x000059f01948d77c	(bluetoothd -device.c:5346)
device_remove
0x000059f019476d14	(bluetoothd -adapter.c:7202)
adapter_remove
0x000059f019476c3e	(bluetoothd -adapter.c:10827)
adapter_cleanup
0x000059f01949d8d7	(bluetoothd -main.c:1114)		main
0x0000787b36185d74	(libc.so.6 -libc-start.c:308)
__libc_start_main
0x000059f019433e39	(bluetoothd + 0x00026e39)		_start
0x00007fff2d2c0127

Reviewed-by: Archie Pusaka <apusaka@chromium.org>
2021-07-14 11:39:53 -07:00
Luiz Augusto von Dentz
8f30f0837d btdev: Add proper checks for own_addr_type for extended advertising
own_addr_type 0x01 and 0x03 shall check that a random address has
properly been set and in case of 0x03 the resolving list actually
contains the irk of the identity address:

BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 4, Part E
page 2596

  'If the advertising set's Own_Address_Type parameter is set to 0x01
  and the random address for the advertising set has not been
  initialized, the Controller shall return the error code Invalid HCI
  Command Parameters (0x12).'

BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 4, Part E
page 2597

  'If the advertising set's Own_Address_Type parameter is set to 0x03,
  the controller's resolving list did not contain a matching entry, and
  the random address for the advertising set has not been initialized,
  the Controller shall return the error code Invalid HCI Command
  Parameters (0x12).'
2021-07-14 11:37:20 -07:00
Yun-Hao Chung
a12c96c2b9 src/adv_monitor: Remove checking in device lost timeout
The time check in device lost timeout could cause DeviceLost never being
reported because of the following reasons:

1. Timer created in timeout_add_seconds, which calls
   g_timeout_add_seconds_full internally, can be fired one second
   earlier than |timeout| seconds.
2. When handle_device_lost_timeout is invoked early, time diff between
   |curr_time| and |last_seen| could be less than |low_rssi_timeout|. In
   this case, since handle_device_lost always returns FALSE, the
   timer will be removed, but DeviceLost has not been reported yet.
3. If we never receives any advertisement from that peer since then,
   DeviceLost will never be reported.

We can remove the checking in handle_device_lost_time because we restart
or remove the timer whenever an advertisement is received.

Reviewed-by: apusaka@chromium.org
Reviewed-by: mcchou@chromium.org
Reviewed-by: mmandlik@chromium.org
2021-07-09 11:43:51 -07:00
Marcel Holtmann
e1432e7b8d Release 5.60 2021-07-07 15:42:45 +02:00
João Paulo Rechi Vita
33b9f85dac profile: Fail RegisterProfile if UUID already exists
If a process tries to register a profile implementation that is already
registered, RegisterProfile should fail.

This should help address issues when two instances of PulseAudio are
running at the same time, and the second instance tries to register an
audio profile implementation that has already been registered by the
first instance. Two situations where this may happen is when more than
one user is logged in, or during the transition between the GDM session
and the user session, when PulseAudio gets started on the new session
before the old session has been fully terminated.

https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/303
https://gitlab.gnome.org/GNOME/gdm/-/issues/486
2021-07-01 15:49:45 -07:00
Tedd Ho-Jeong An
77dba3b4d9 emulator/btdev: clean up the queue before closing the test
This patch clean up the queue for connection before closing the test to
prevent the potential memory leak.

==50== 32 bytes in 1 blocks are definitely lost in loss record 18 of 32
==50==    at 0x483A809: malloc (vg_replace_malloc.c:307)
==50==    by 0x14A37E: btd_malloc (util.c:33)
==50==    by 0x149D9D: queue_new (queue.c:47)
==50==    by 0x13B3C0: btdev_create (btdev.c:6042)
==50==    by 0x13178E: create_vhci (hciemu.c:229)
==50==    by 0x13178E: hciemu_new_num (hciemu.c:403)
==50==    by 0x130E2C: read_index_list_callback (mgmt-tester.c:357)
==50==    by 0x14AD91: request_complete (mgmt.c:264)
==50==    by 0x14BD34: can_read_data (mgmt.c:356)
==50==    by 0x14E794: watch_callback (io-glib.c:157)
==50==    by 0x48B578E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==    by 0x48B5B17: ??? (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==    by 0x48B5E32: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==
==50== 32 bytes in 1 blocks are definitely lost in loss record 19 of 32
==50==    at 0x483A809: malloc (vg_replace_malloc.c:307)
==50==    by 0x14A37E: btd_malloc (util.c:33)
==50==    by 0x149D9D: queue_new (queue.c:47)
==50==    by 0x13B3C0: btdev_create (btdev.c:6042)
==50==    by 0x1318F7: hciemu_client_new (hciemu.c:332)
==50==    by 0x1318F7: hciemu_new_num (hciemu.c:412)
==50==    by 0x130E2C: read_index_list_callback (mgmt-tester.c:357)
==50==    by 0x14AD91: request_complete (mgmt.c:264)
==50==    by 0x14BD34: can_read_data (mgmt.c:356)
==50==    by 0x14E794: watch_callback (io-glib.c:157)
==50==    by 0x48B578E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==    by 0x48B5B17: ??? (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==    by 0x48B5E32: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.6)
2021-07-01 14:26:01 -07:00
Luiz Augusto von Dentz
a19b0d594b test-runner: Use src/main.conf if available
This makes use of src/main.conf as configuration file that way custom
options can be applied while running the daemon.
2021-06-28 13:43:03 -07:00
Howard Chung
10d1acb1f4 shared/gatt-client: Fix GATT client attribute read with offset
bluez always replies the whole value despite a user specify the offset.
This patch fixes the issue.

Reviewed-by: sonnysasaka@chromium.org
2021-06-28 10:34:02 -07:00
Luiz Augusto von Dentz
5c76125737 adapter: Fix toggling of experimental features
When toggling experimental features it may cause the old value to still
be in effect since it was read after read info which upon completion
would attempt to call adapter_register without first updating the
experimental features which could affect the likes of advertising
instances when LL Privacy is enabled.
2021-06-24 15:07:56 -07:00
David Lechner
b3451a205f doc/advmon-api: Clarify Patterns property
The Patterns property description was not as clear as it could be. This
expands the text a bit, replaces the C enum value 0x01 with the D-Bus
property string value "or_patterns" and improves the grammar in a few
places.
2021-06-24 13:11:27 -07:00
Manish Mandlik
9b9da91979 adv_monitor: Avoid skipping non-discoverable dev on Monitor match
Do no skip a non-discoverable device if it matches any Advertisement
Monitor.

Reviewed-by: mcchou@google.com
Reviewed-by: alainmichaud@google.com
2021-06-24 11:20:18 -07:00
Luiz Augusto von Dentz
ee0f3c03fb media: Fix UnregisterApplication
UnregisterApplication is not doing anything since the apps queue is
never initialized which results in not finding any application when
unregistering.

Fixes: https://github.com/bluez/bluez/issues/126
2021-06-23 15:45:08 -07:00
Benjamin Berg
c939747f54 rfkill: Fix reading from rfkill socket
The kernel will always send exactly one event, but the size of the
passed struct will depend on the length of the submitted read() and the
kernel version. i.e. the interface can be extended and we need to expect
for a read to be longer than expected if we ask for it.

Fix this by only requesting the needed length and explicitly check the
length against the V1 version of the structure to make the code a bit
more future proof in case the internal copy of the struct is updated to
contain new fields.
2021-06-23 15:33:45 -07:00
Tedd Ho-Jeong An
4da8cec318 tools/mgmt-tester: Update to support multiple extended adv instances
This patch updates to align with the multiple extended advertising
support.
2021-06-23 11:51:11 -07:00
Tedd Ho-Jeong An
468d6f1191 emulator/bthost: Create ext adv params before setting adv data
Based on the SPEC 5.2 Vol 4, Part E, Section 7.8.54, the
LE_Set_Extended_Advertising_Data_Command may be issued after an
advertising set identifed by the Advertising_Handle has been created
using the HCI_LE_Set_Extended_Advertising_Parameters command.
2021-06-23 11:51:11 -07:00
Luiz Augusto von Dentz
d9979f26e6 emulator/btdev: Add support HCI LE Adv Set Terminated event
This patch adds support the HCI_LE_Advertising_Set_Terminated event in
btdev.
2021-06-23 11:51:10 -07:00
Tedd Ho-Jeong An
5145b1ea2e emulator/btdev: Add support multiple instance of extended advertising
This patch adds support multiple instance of extended advertising.
2021-06-23 11:51:10 -07:00
Tedd Ho-Jeong An
f5cc75fc54 tools/mgmt-tester: Enable High-Speed(HS) test cases
This patch enables the BT High-Speed(HS) test cases by enabling the HS
in the kernel config.
2021-06-23 11:51:10 -07:00
Luiz Augusto von Dentz
864d03727d device: Fix enabling temporary timer when TemporaryTimeout=0
When TemporaryTimeout is set to 0 it is supposed to disable the
temporary timeout so devices never desappear.

Fixes: https://github.com/bluez/bluez/issues/146
2021-06-18 15:41:42 -07:00
Archie Pusaka
0388794dc5 avdtp: Fix parsing capabilities
This patch fixes size comparison and variable misassignment.

Reviewed-by: Alain Michaud <alainm@chromium.org>
Reviewed-by: Michael Sun <michaelfsun@google.com>
2021-06-17 13:47:11 -07:00
Alain Michaud
dda85ae73f monitor: Adding missing device found flag in the parser
A new flag was added to the kernel implementation of the Device Found
event, but had not been added to the parser leading to an "Unknown device
flag" error in btmon.

Reviewed-by: Yu Liu <yudiliu@google.com>
2021-06-16 15:33:39 -07:00
Sebastian Urban
40f996c64a gatt-client: Check length of notify multiple op
Check that specfied length of value in received data does not exceed
length of PDU. Otherwise data may be read from beyond the end of the
buffer.
2021-06-16 08:20:08 -07:00
Luiz Augusto von Dentz
352cee4717 mgmt-tester: Fix typo
This fixes debup typo.
2021-06-16 08:18:40 -07:00
Luiz Augusto von Dentz
c3db40eee8 monitor: Fix typos
This fixes interval typos.
2021-06-15 15:30:44 -07:00
Marcel Holtmann
2c405706e1 doc: Add initial draft of security bugs handling document 2021-06-15 22:12:16 +02:00
Sebastian Urban
6278a71040 gatt-database: No multiple calls to AcquireWrite
This checks if an outstanding call to AcquireWrite is already in
progress. If so, the write request is placed into the queue, but
AcquireWrite is not called again. When a response to AcquireWrite is
received, acquire_write_reply sends all queued writes over the acquired
socket.

Making multiple simultaneous calls to AcquireWrite makes no sense,
as this would open multiple socket pairs and only the last returned
socket would be used for further writes.
2021-06-14 13:59:54 -07:00
Sebastian Urban
297fa5cb3e gatt-server: Flush notify multiple buffer when full and fix overflow
This fixes the calculation of available buffer space in
bt_gatt_server_send_notification and sends pending notifications
immediately when there is no more room to add a notification.

Previously there was a buffer overflow caused by incorrect calculation
of available buffer space: data->offset can equal data->len
from a previous call to this function, leading
(data->len - data->offset) to underflow after data->offset += 2.
2021-06-14 13:59:46 -07:00
Luiz Augusto von Dentz
d31dfe8c7d mgmt-tester: Enable Kernel Debug Experimental Feature
This attempts to enable Kernel Debug Experimental Feature if debug is
enabled.
2021-06-14 10:46:08 -07:00