Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ v2 00/16] Channel Sounding and RAP fixes
@ 2026-11-18 19:58 Luiz Augusto von Dentz
  2026-11-18 19:58 ` [PATCH BlueZ v2 01/16] gatt-database: Drop stale device state for removed bonds Luiz Augusto von Dentz
                   ` (15 more replies)
  0 siblings, 16 replies; 20+ messages in thread
From: Luiz Augusto von Dentz @ 2026-11-18 19:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This series fixes the Ranging Profile Requester and Reflector setup
and RAS server issues found while running the RAP and RAS PTS tests
(Channel Sounding with a Reflector, peer-created configurations,
Ranging Data subscriptions, per-connection Ranging Counters), plus a
GATT database CCC state leak and a use-after-free in bluetoothctl.

v2:
- gatt-database: clear the cached state of both bearers of a dual-mode
  device when it is removed.
- shared/rap: keep the Ranging Data Ready and Overwritten counters per
  connection instead of resetting the adapter-wide state on detach.
- profiles/ranging: exclude armed Reflector sessions from the Active
  property.
- profiles/ranging: ignore Remote Supported Capabilities of unmapped
  handles, so one link cannot overwrite another's antenna limits.
- profiles/ranging: enter CS_STATE_INIT before the asynchronous
  capability reads, so a peer-created configuration is not rewound.
- unit/test-rap: add tests for the Requester Ranging Data subscriptions,
  the Real-time timeout and the per-connection counters.

Cheng Jiang (15):
  gatt-database: Drop stale device state for removed bonds
  shared/rap: Reset the readable Ranging Counters per connection
  shared/rap: Subscribe on-demand data with the requested transport
  shared/rap: Subscribe to Ranging Data when a measurement starts
  client/cs: Fix use-after-free in stop_measurement_reply
  shared/hci: Look up the connection handle on the right link
  profiles/ranging: Let the Reflector run the CS setup phase
  profiles/ranging: Let StartMeasurement() pick the Initiator for Both
  profiles/ranging: Take the CS role from Config Complete
  profiles/ranging: Act on a CS configuration created by the peer
  profiles/ranging: Keep a peer-driven setup from being rewound
  profiles/ranging: Defer CS Security Enable until the link is encrypted
  profiles/ranging: Choose the CS antenna configuration from both ends
  profiles/ranging: Do not start a procedure after StopMeasurement()
  shared/rap: Start the Real-time timeout when the procedure starts

Luiz Augusto von Dentz (1):
  unit/test-rap: Add tests for Ranging Data subscription and counters

 client/cs.c                        |  40 ++-
 doc/org.bluez.ChannelSounding1.rst |  21 +-
 lib/bluetooth/hci.h                |   1 +
 profiles/ranging/rap.c             |  28 +-
 profiles/ranging/rap_hci.c         | 431 +++++++++++++++++++-----
 src/device.c                       |   3 +
 src/gatt-database.c                |  30 ++
 src/gatt-database.h                |   2 +
 src/shared/hci.c                   |  12 +-
 src/shared/hci.h                   |   2 +-
 src/shared/rap.c                   |  98 ++++--
 src/shared/rap.h                   |   6 +-
 tools/hcitool.c                    |   3 -
 unit/test-rap.c                    | 507 ++++++++++++++++++++++++++---
 14 files changed, 985 insertions(+), 199 deletions(-)

-- 
2.56.0


^ permalink raw reply	[flat|nested] 20+ messages in thread
* [PATCH BlueZ 01/15] gatt-database: Drop stale device state for removed bonds
@ 2026-11-02  8:18 Cheng Jiang
  2026-11-02  9:08 ` Channel Sounding and RAP fixes bluez.test.bot
  2026-11-17 12:15 ` bluez.test.bot
  0 siblings, 2 replies; 20+ messages in thread
From: Cheng Jiang @ 2026-11-02  8:18 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: jinwang.li, wei.deng, xiuzhuo.shang, shuai.zhang, Cheng Jiang

When a device is removed while disconnected, its cached CCC state
stays in the GATT database and is restored on the next connection.
Drop that state from device_remove() so a re-paired device starts
clean.

Assisted-by: Claude:claude-haiku-5-5
---
 src/device.c        |  3 +++
 src/gatt-database.c | 25 +++++++++++++++++++++++++
 src/gatt-database.h |  2 ++
 3 files changed, 30 insertions(+)

diff --git a/src/device.c b/src/device.c
index 4567188d6..6179c4777 100644
--- a/src/device.c
+++ b/src/device.c
@@ -5629,6 +5629,9 @@ void device_remove(struct btd_device *device, gboolean remove_stored)
 {
 	DBG("Removing device %s", device->path);
 
+	btd_gatt_database_remove_device(
+			btd_adapter_get_database(device->adapter), device);
+
 	if (device->auth_retry_id) {
 		device->auth_retry_id = 0;
 		timeout_remove(device->auth_retry_id);
diff --git a/src/gatt-database.c b/src/gatt-database.c
index d8e45581a..a7480a7f8 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -4251,6 +4251,31 @@ void btd_gatt_database_att_disconnected(struct btd_gatt_database *database,
 	att_disconnected(0, state);
 }
 
+void btd_gatt_database_remove_device(struct btd_gatt_database *database,
+						struct btd_device *device)
+{
+	struct device_state *state;
+	const bdaddr_t *addr;
+	uint8_t type;
+
+	addr = device_get_address(device);
+	type = btd_device_get_bdaddr_type(device);
+
+	state = find_device_state(database, addr, type);
+	if (!state)
+		return;
+
+	/* While connected, gatt_server_cleanup() still reaches the state
+	 * through the disconnect callback, so leave it alone here.
+	 */
+	if (state->disc_id)
+		return;
+
+	queue_foreach(state->ccc_states, clear_ccc_state, state->db);
+	queue_remove(database->device_states, state);
+	device_state_free(state);
+}
+
 static void restore_ccc(struct btd_gatt_database *database,
 			const bdaddr_t *addr, uint8_t addr_type, uint16_t value)
 {
diff --git a/src/gatt-database.h b/src/gatt-database.h
index 998e3c452..94469a707 100644
--- a/src/gatt-database.h
+++ b/src/gatt-database.h
@@ -20,6 +20,8 @@ btd_gatt_database_get_adapter(struct btd_gatt_database *database);
 
 void btd_gatt_database_att_disconnected(struct btd_gatt_database *database,
 						struct btd_device *device);
+void btd_gatt_database_remove_device(struct btd_gatt_database *database,
+						struct btd_device *device);
 void btd_gatt_database_server_connected(struct btd_gatt_database *database,
 						struct bt_gatt_server *server);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2026-11-19  1:57 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 19:58 [PATCH BlueZ v2 00/16] Channel Sounding and RAP fixes Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 01/16] gatt-database: Drop stale device state for removed bonds Luiz Augusto von Dentz
2026-11-19  1:57   ` Channel Sounding and RAP fixes bluez.test.bot
2026-11-18 19:58 ` [PATCH BlueZ v2 02/16] shared/rap: Reset the readable Ranging Counters per connection Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 03/16] shared/rap: Subscribe on-demand data with the requested transport Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 04/16] shared/rap: Subscribe to Ranging Data when a measurement starts Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 05/16] client/cs: Fix use-after-free in stop_measurement_reply Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 06/16] shared/hci: Look up the connection handle on the right link Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 07/16] profiles/ranging: Let the Reflector run the CS setup phase Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 08/16] profiles/ranging: Let StartMeasurement() pick the Initiator for Both Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 09/16] profiles/ranging: Take the CS role from Config Complete Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 10/16] profiles/ranging: Act on a CS configuration created by the peer Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 11/16] profiles/ranging: Keep a peer-driven setup from being rewound Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 12/16] profiles/ranging: Defer CS Security Enable until the link is encrypted Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 13/16] profiles/ranging: Choose the CS antenna configuration from both ends Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 14/16] profiles/ranging: Do not start a procedure after StopMeasurement() Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 15/16] shared/rap: Start the Real-time timeout when the procedure starts Luiz Augusto von Dentz
2026-11-18 19:58 ` [PATCH BlueZ v2 16/16] unit/test-rap: Add tests for Ranging Data subscription and counters Luiz Augusto von Dentz
  -- strict thread matches above, loose matches on Subject: below --
2026-11-02  8:18 [PATCH BlueZ 01/15] gatt-database: Drop stale device state for removed bonds Cheng Jiang
2026-11-02  9:08 ` Channel Sounding and RAP fixes bluez.test.bot
2026-11-17 12:15 ` bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox