Commit Graph

26427 Commits

Author SHA1 Message Date
Luiz Augusto von Dentz
f65a9c9d21 btmon: Fix not decoding LC3 id
This enablind decoding LC3 codec id (0x06).
2022-04-26 16:02:54 -07:00
Luiz Augusto von Dentz
80cd36cd2a btmon: Add support for decoding Basic Audio Annoucements
This adds support for decoding Basic Audio Announcements as shown
on:

Basic Audio Profile / Profile Specification
Page 36 of 146

Table 3.15: Format of BASE used in Basic Audio Announcements

< HCI Command: LE Set Periodic Advertising Data (0x08|0x003f) plen 36
        Handle: 0
        Operation: Complete ext advertising data (0x03)
        Data length: 0x21
        Service Data: Basic Audio Announcement (0x1851)
          Presetation Delay: 40000
          Number of Subgroups: 1
            Subgroup #0:
            Number of BIS(s): 1
            Codec: Reserved (0x06)
            Codec Specific Configuration: 010101020403010000020428
            Metadata: 020202
              BIS #0:
              Index: 1
              Codec Specific Configuration:
2022-04-26 16:00:53 -07:00
Luiz Augusto von Dentz
6da642225f btmon: Add support for decoding Broadcast Audio Annoucements
This adds support for decoding Broadcast Audio Announcements as shown
on:

Basic Audio Profile / Profile Specification
Page 34 of 146

Table 3.14: Broadcast Source AD format when transmitting Broadcast
Audio Announcements

< HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 36
        Handle: 0x00
        Operation: Complete extended advertising data (0x03)
        Fragment preference: Minimize fragmentation (0x01)
        Data length: 0x20
        Service Data: Broadcast Audio Announcement (0x1852)
        Broadcast ID: 904177 (0x0dcbf1)
        Name (complete): Broadcast Audio Source
2022-04-26 15:59:48 -07:00
Luiz Augusto von Dentz
640d6b5c66 btmon: Add proper decoding to Service Data UUID
This adds proper decoding for Service Data UUID:

        Service Data: Apple, Inc. (0xfd6f)
          Data: e6b07e19815e902100b8b2f4a55255fd18f0c6be
2022-04-26 11:39:14 -07:00
Luiz Augusto von Dentz
7a87497da4 client/player: Add transport.receive command
This adds transport.receive command:

Get/Set file to receive
Usage:
	 receive [filename]
2022-04-26 11:03:26 -07:00
Luiz Augusto von Dentz
dd5b66695c client/player: Add transport.volume command
This adds transport.volume command:

Get/Set transport volume
Usage:
	 volume <transport> [value]
2022-04-22 16:01:29 -07:00
Luiz Augusto von Dentz
3e2ad5009c btmon: Fix decoding of Enhanced Credit Connection Request
This fixes the decoding of Enhanced Credit Connection Request which was
not accounting the fields correctly causing 2 extra Source CID to be
printed.
2022-04-22 13:03:50 -07:00
Luiz Augusto von Dentz
c535623a71 hog-lib: Check if Report ID is set before prepending it
Before prepending the Report ID check if it is non-zero:

BLUETOOTH SPECIFICATION Page 16 of 26
HID Service Specification

Report ID shall be nonzero in a Report Reference characteristic
descriptor where there is more than one instance of the Report
characteristic for any given Report Type.

Fixes: https://www.spinics.net/lists/linux-bluetooth/msg97262.html
2022-04-22 13:03:34 -07:00
Diego Rondini
a1939bd51e test: changes for Python3
Remove some leftover usage of Python2 code. In particular replace
iteritems() with items() to fix the following error:

AttributeError: 'dbus.Dictionary' object has no attribute 'iteritems'
2022-04-19 15:32:16 -07:00
Luiz Augusto von Dentz
832b594a25 settings-storage: Document use of StateDirectory
This documents the use of StateDirecory environment variable which
overwrites the default storage diretory when set.
2022-04-19 11:34:25 -07:00
Luiz Augusto von Dentz
00cfb36e20 bluetooth.service: Set ConfigurationDirectoryMode
This sets ConfigurationDirectoryMode to 0555 to really enforce the
ConfigurationDirectory to be read-only [1].

[1] https://github.com/bluez/bluez/issues/329#issuecomment-1102459104
2022-04-19 11:18:59 -07:00
Luiz Augusto von Dentz
edc69d2534 bluetooth.service: Set StateDirectoryMode
This sets StateDirectoryMode to 0700 as it is the current mode used for
creating files inside the storage and it is different than the default
systemd uses which is 0755:

[1] https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDirectoryMode=
2022-04-19 11:07:40 -07:00
Luiz Augusto von Dentz
b2db8f0e3a client/player: Fix use of unsupported config_qos
QoS is not yet supported by bluetoothd so remove them.
2022-04-18 16:57:49 -07:00
Luiz Augusto von Dentz
fb4997fb09 test-runner: Add dedicated option to start D-Bus
This adds a dedicated option to start D-Bus alone which can be useful
when testing the bluetoothd with the likes of valgrind.
2022-04-18 16:53:00 -07:00
Luiz Augusto von Dentz
0905a06410 build: Make use of StateDirectory and ConfigurationDirectory
This makes use of StateDirectory[1] and ConfigurationDirectory[1] to
inform systemd what those paths are used for instead of using
ReadWritePaths and ReadOnlyPaths which can lead to issues.

Fixes: https://github.com/bluez/bluez/issues/329

[1] https://www.freedesktop.org/software/systemd/man/systemd.exec.html
2022-04-18 16:52:59 -07:00
Luiz Augusto von Dentz
385e8d649e main: Add support for CONFIGURATION_DIRECTORY environment variable
When running as a systemd service the CONFIGURATION_DIRECTORY
environment variable maybe set:

https://www.freedesktop.org/software/systemd/man/systemd.exec.html
2022-04-18 16:52:58 -07:00
Luiz Augusto von Dentz
5fb27418e7 storage: Add support for STATE_DIRECTORY environment variable
When running as a systemd service the STATE_DIRECTORY environment
variable maybe set:

https://www.freedesktop.org/software/systemd/man/systemd.exec.html
2022-04-18 16:52:56 -07:00
Luiz Augusto von Dentz
180cf09933 policy: Change AutoEnable default to true
This changes the default of AutoEnable to true so controllers are power
up by default.

Fixes: https://github.com/bluez/bluez/issues/328
2022-04-14 17:05:25 -07:00
Luiz Augusto von Dentz
777bc7c3f5 client/player: Add transport menu
This adds transport menu:

[bluetooth]# menu transport
Menu transport:
Available commands:
-------------------
list                                              List available transports
show <transport>                                  Transport information
acquire <transport>                               Acquire Transport
release <transport>                               Release Transport
send <filename>                                   Send contents of a file
2022-04-14 17:05:25 -07:00
Luiz Augusto von Dentz
46f171a86c client/player: Add endpoint menu
This adds endpoint menu:

[bluetooth]# menu endpoint
Menu endpoint:
Available commands:
-------------------
list [local]                                      List available endpoints
show <endpoint>                                   Endpoint information
register <UUID> <codec> [capabilities...]         Register Endpoint
unregister <UUID/object>                          Register Endpoint
config <endpoint> <local endpoint> [preset]       Configure Endpoint
presets <UUID> [default]                          List available presets
2022-04-14 17:05:24 -07:00
Luiz Augusto von Dentz
03602479bd btdev: Fix CIS Established
CIS Established was using the ISO latency instead of SDU interval for
transport latency.
2022-04-14 17:05:23 -07:00
Luiz Augusto von Dentz
f9f2b28d45 bthost: Fix not setting all parameters when using Create BIG cmd
Create BIG shall set proper values for interval, latency, rtn and phy.
2022-04-14 17:05:22 -07:00
Luiz Augusto von Dentz
dc1b309901 bthost: Add support for Create CIS
This introduces bthost_set_cig_params and bthost_create_cis.
2022-04-14 17:05:21 -07:00
Luiz Augusto von Dentz
1967b53115 btdev: Fix not cleanup ssp_status and ssp_auto_complete
This resets ssp_status and ssp_auto_complete flags on auth_complete.
2022-04-13 14:12:28 -07:00
Jakob hilmer
7903bbe100 adapter: Fix check of DISCOVERABLE setting
The test for `DISCOVERABLE` should be done with
`MGMT_SETTING_DISCOVERABLE` instead of `MGMT_OP_SET_DISCOVERABLE`.
Acked-by: Paul Menzel <pmenzel@molgen.mpg.de>
2022-04-11 11:09:30 -07:00
Luiz Augusto von Dentz
195d9b80e1 shell: Fix not able to auto complete commands with submenu prefix
If the command was given with submenu prefix the code wasn't able to
detect the command to be able to generate the auto complete for its
arguments.
2022-04-11 11:06:33 -07:00
Luiz Augusto von Dentz
f547db04fd shell: Fix not being able to auto complete submenus
submenus should be part of the list of possible auto completes just as
other commands.
2022-04-11 11:06:33 -07:00
Luiz Augusto von Dentz
d1871fc935 btdev: Fix BIG Create Sync
This fixes status return to BIG Create Sync command.
2022-04-06 15:02:00 -07:00
Luiz Augusto von Dentz
1094889133 btdev: Add support for sending LE BIG Info Adv Reports
This adds support for sending LE BIG Info Adv Reports if LE Create BIG
has been called.
2022-04-06 15:01:59 -07:00
Luiz Augusto von Dentz
0533085d22 monitor: Add support for LE BIG Info Adverting Report
This adds support for LE BIG Info Advertising Report.
2022-04-06 15:01:59 -07:00
Luiz Augusto von Dentz
bbeabca44a gap: Don't attempt to read the appearance if already set
Devices are unlikely to change appearance over time which is the reason
why we cache then on the storage so this skips reading it on every
reconnection.
2022-04-04 13:15:18 -07:00
Ildar Kamaletdinov
3627eddea1 gatt: Fix double free and freed memory dereference
If device is no longer exists or not paired when notifications send it
is possible to get double free and dereference of already freed memory.

To avoid this we need to recheck the state of device after sending
notification.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.
2022-04-04 09:42:00 -07:00
Ildar Kamaletdinov
4afbef7790 device: Limit width of fields in sscanf
In src/device.c few sscanf does not limit width of uuid field. This
could lead to static overflow and stack corruption.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.
2022-04-04 09:41:59 -07:00
Ildar Kamaletdinov
1e664b9838 tools: Limit width of fields in sscanf
In tools/btmgmt.c and tools/hex2hcd.c few sscanf does not limit width
of fields. This could lead to static overflow and stack corruption.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.
2022-04-04 09:41:59 -07:00
Ildar Kamaletdinov
497a0b220d tools: Fix signed integer overflow in btsnoop.c
If malformed packet is proceed with zero 'size' field we will face with
wrong behaviour of write() call. Value 'toread - 1' gives wrong sign
for value 'written' (-1) in write() call. To prevent this we should
check that 'toread' is not equal to zero.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.
2022-04-04 09:41:59 -07:00
Ildar Kamaletdinov
d328abaa17 tools: Fix buffer overflow in hciattach_tialt.c
Array 'c_brf_chip' of size 8 could be accessed by index > 7. We should
limit array access like in previous check at line 221.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.
2022-04-04 09:41:58 -07:00
Ildar Kamaletdinov
7fdfb67284 monitor: Fix out-of-bound read in print_le_states
Accessing le_states_desc_table array with value 15 can cause
out-of-bound read because current size of array is 14.

Currently this cannot lead to any problems becase we do no have such
state in le_states_comb_table but this could be changed in future and
raise described problem.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.
2022-04-04 09:41:58 -07:00
Frédéric Danis
0f382885d4 tools: Fix g_dbus_setup_private connection check in mpris-proxy 2022-04-04 09:41:22 -07:00
Luiz Augusto von Dentz
234d60423c shared/gatt-db: Fix gatt_db_attribute_get_index
gatt_db_attribute_get_index was calculating the index based on
attrib->handle - service->attributes[0]->handle which doesn't work when
there are gaps in between handles.

Fixes: https://github.com/bluez/bluez/issues/326
2022-04-01 16:25:00 -07:00
Luiz Augusto von Dentz
6d15315570 btdev: Check parameter for CIG related commands
This checks if the parameters given to Set CIG Parameters and Remove CIG
are in the valid range.
2022-04-01 16:24:55 -07:00
Inga Stotland
ff35b1d2e9 mesh: use explicit uint32_t when bit shifting left
This addresses a situation when a boolean type is represented by
an integer and performing a left shift on a boolean causes
an integer overflow.

This fixes the following runtime error:
"left shift of 1 by 31 places cannot be represented in type 'int'"
2022-03-31 11:21:56 -07:00
Frédéric Danis
4a06a31be0 a2dp: Fix crash when SEP codec has not been initialized
If SEP has not been properly discovered avdtp_get_codec may return NULL
thus causing crashes such as when running AVRCP/TG/VLH/BI-01-C after
AVRCP/TG/RCR/BV-04-C.

Prevent remote endpoint registration if its codec is not available.

Remove queue_isempty check from store_remote_seps since that prevents
cleaning up if no seps could be registered.
2022-03-30 12:54:54 -07:00
Luiz Augusto von Dentz
d204e84c06 client: Add support for player submenu
This moves adds the functionality of bluetooth-player into
bluetoothctl.
2022-03-30 12:54:29 -07:00
Luiz Augusto von Dentz
0cc480a546 shell: Make bt_shell_add_submenu set main menu if none has been set
If not main menu has been set when calling bt_shell_add_submenu then
turns it on it main menu.
2022-03-30 12:54:24 -07:00
Luiz Augusto von Dentz
6cb6e2ddf4 mgmt: Remove mgmt_set_verbose
The likes of btmon already decode the commands/events so there is no
need to have the code hexdump their contents.
2022-03-28 10:51:27 -07:00
Luiz Augusto von Dentz
62e591578e a2dp: Always invalidate the cache if its configuration fails
When a configuration had been restored from last_used cache but it
fails invalidate it so another sep can be used.

Fixes: https://github.com/bluez/bluez/issues/313
2022-03-28 10:51:27 -07:00
Luiz Augusto von Dentz
18fc3abad2 a2dp: Don't initialize a2dp_sep->destroy until properly registered
On a2dp_add_sep if the record cannot be properly registred
a2dp_unregister_sep would be called which would attempt to destroy the
user_data causing the following backtrace:

Invalid write of size 8
   at 0x2F41EB: endpoint_init_a2dp_source (media.c:687)
   by 0x2F41EB: media_endpoint_create (media.c:1030)
   by 0x2F6713: register_endpoint (media.c:1155)
   by 0x46983F: process_message (object.c:246)
   by 0x4A574A8: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.19.14)
   by 0x45F0BF: message_dispatch (mainloop.c:59)
   by 0x495239A: ??? (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x495605E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x49AB2A7: ??? (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x4955772: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x4CA924: mainloop_run (mainloop-glib.c:66)
   by 0x4CAE1B: mainloop_run_with_signal (mainloop-notify.c:188)
   by 0x2AE791: main (main.c:1258)
 Address 0x6e47a30 is 0 bytes inside a block of size 112 free'd
   at 0x48470E4: free (vg_replace_malloc.c:872)
   by 0x4957CDC: g_free (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x2C2D57: a2dp_unregister_sep (a2dp.c:2588)
   by 0x2D124C: a2dp_add_sep (a2dp.c:2697)
   by 0x2F41D5: endpoint_init_a2dp_source (media.c:687)
   by 0x2F41D5: media_endpoint_create (media.c:1030)
   by 0x2F6713: register_endpoint (media.c:1155)
   by 0x46983F: process_message (object.c:246)
   by 0x4A574A8: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.19.14)
   by 0x45F0BF: message_dispatch (mainloop.c:59)
   by 0x495239A: ??? (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x495605E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.7000.4)
   by 0x49AB2A7: ??? (in /usr/lib64/libglib-2.0.so.0.7000.4)
2022-03-28 10:51:27 -07:00
Luiz Augusto von Dentz
4fefa24097 adapter: Fix adding SDP records when operating on LE only mode
If mode is set to BT_MODE_LE SDP protocol won't be operational so it is
useless to attempt to add records.
2022-03-28 10:51:27 -07:00
Inga Stotland
2a2b027176 mesh: Fix address overrun error in rx filter
This fixes the following error for invalid read access when registering
filter for incoming messages:

140632==ERROR: AddressSanitizer: stack-buffer-overflow on address...
 #0 0x7f60c185741d in MemcmpInterceptorCommon(...
    #1 0x7f60c1857af8 in __interceptor_memcmp (/lib64/libasan.so...
    #2 0x55a10101536e in find_by_filter mesh/mesh-io-unit.c:494
    #3 0x55a1010d8c46 in l_queue_remove_if ell/queue.c:517
    #4 0x55a101014ebd in recv_register mesh/mesh-io-unit.c:506
    #5 0x55a10102946f in mesh_net_attach mesh/net.c:2885
    #6 0x55a101086f64 in send_reply mesh/dbus.c:153
    #7 0x55a101124c3d in handle_method_return ell/dbus.c:216
    #8 0x55a10112c8ef in message_read_handler ell/dbus.c:276
    #9 0x55a1010dae20 in io_callback ell/io.c:120
    #10 0x55a1010dff7e in l_main_iterate ell/main.c:478
    #11 0x55a1010e06e3 in l_main_run ell/main.c:525
    #12 0x55a1010e06e3 in l_main_run ell/main.c:507
    #13 0x55a1010e0bfc in l_main_run_with_signal ell/main.c:647
    #14 0x55a10100316e in main mesh/main.c:292
    #15 0x7f60c0c6855f in __libc_start_call_main (/lib64/libc.so.6+...
    #16 0x7f60c0c6860b in __libc_start_main_alias_1 (/lib64/libc.so.6+...
    #17 0x55a101003ce4 in _start (/home/istotlan/bluez/mesh/bluetooth-m...
2022-03-26 09:48:58 -07:00
Luiz Augusto von Dentz
71cec503c8 device: Don't use DBG in gatt_debug
gatt_debug callback is used to print debug strings from bt_att which
includes the file and function names so using DBG would add yet another
set of file and function prefixes which makes the logs confusing.
2022-03-23 15:39:45 -07:00