Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ 00/15] Channel Sounding and RAP fixes
@ 2026-11-02  8:18 Cheng Jiang
  2026-11-02  8:18 ` [PATCH BlueZ 01/15] gatt-database: Drop stale device state for removed bonds Cheng Jiang
                   ` (15 more replies)
  0 siblings, 16 replies; 18+ 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

This series fixes problems found while running the RAP Requester (RREQ),
RAS Server (RAS/SR) and GAP CS test cases against PTS. So far the
Channel Sounding code had mostly been used between two BlueZ devices,
with the local side creating the configuration as the Initiator. The
test cases also cover the Reflector role, a configuration created by
the peer, peers with different antenna counts and every Ranging Data
mode, and most of the fixes are for those paths.

The patches do not depend on how the CS session is created; they apply
to the existing session set up from the RAP profile probe. Creating a
session for a peer without the Ranging Service is a separate question,
which I sent to the list earlier and is not part of this series.

GATT database and RAS (patches 1-4 and 15)
==========================================

 1. A device removed while disconnected kept its CCC state in the GATT
    database, and it was restored when the device paired again. Drop it
    from device_remove().

 2. The Ranging Counters read from Ranging Data Ready and Ranging Data
    Overwritten are scoped to the connection (RAS v1.0 3.4 and 3.5),
    but were never cleared, so a new connection read the counter of the
    previous one. Clear them in bt_rap_detach().

 3. On-demand Ranging Data was always subscribed with notifications,
    while the RAS Control Point, which only supports indications,
    followed the requested transport; with notifications no On-demand
    transfer could be requested. Follow RAS v1.0 Table 3.1: the
    requested transport for On-demand Ranging Data, indications for the
    Control Point, and indications for Ready and Overwritten whenever
    the server supports them.

 4. Reading RAS Features subscribed to Real-time Ranging Data at
    connection time, when no procedure is running yet, so the 5 s timer
    disabled it again. Subscribe when StartMeasurement() is called
    instead, unless SetRangingDataMode() already did, and use On-demand
    when the peer lacks Real-time Ranging Data (RAP v1.0 4.4.2).

15. RAP v1.0 4.4.1.1 counts the 5 s Real-time timeout from the start of
    the CS procedure, but the timer started when the CCCD was written,
    possibly seconds earlier. Start it from CS Procedure Enable
    Complete.

bluetoothctl and shared/hci (patches 5-6)
=========================================

 5. Fix a use-after-free in the StopMeasurement() reply of
    bluetoothctl, where the Active=false property change had already
    freed the session.

 6. bt_hci_get_conn_handle() always listed the connections of hci0 and
    took the first link matching the address, which could be a BR/EDR
    ACL or an old link being torn down. Use the right controller index
    and match the link type; this adds LE_LINK to lib/bluetooth/hci.h,
    replacing the local copy in hcitool.

CS role and setup in profiles/ranging (patches 7-14)
====================================================

These depend on each other and are best applied in order.

 7. StartMeasurement() returned early for a Reflector, so it never ran
    the setup phase and dropped every event the remote Initiator
    drove. Run the setup phase for the Reflector too, subscribe to
    Ranging Data as for an Initiator (the RAP roles are independent of
    the CS roles), and do not send Procedure Enable on stop when no
    procedure runs.

 8. With Role_Enable permitting both roles, the GAP role decided which
    one was used. Since the setup phase only runs from
    StartMeasurement(), take the Initiator role, and tolerate the LL
    Procedure Collision that two simultaneous configuration requests
    can cause.

 9. Config Complete overwrote the Role_Enable value with the negotiated
    role, so a second StartMeasurement() sent an invalid Role_Enable.
    Keep the two in separate fields, and do not send Procedure Enable
    from a Reflector.

10. Config Complete was only parsed in the state reached during a local
    setup, so a configuration created by the peer was dropped. Parse it
    in any state, ignore events for other links, and ignore a removal
    whose parameters are undefined.

11. The Set Default Settings response rewound a setup the peer had
    already advanced, and an Initiator then created a second
    configuration. Only advance from the initial state.

12. CS Security Enable needs an encrypted link (Core v6.2 Vol 4 Part E
    7.8.133). When the configuration completed before encryption, the
    command was never sent. Defer it to the Encryption Change event.

13. The antenna configuration was always ACI 7 (2:2) unless the
    application set another, which a single-antenna Controller on
    either end rejects. Choose one that fits both ends' capabilities
    and the negotiated role (Core v6.2 Vol 6 Part A, Table 5.3).

14. A StopMeasurement() during the setup phase did not stop it, and the
    Initiator went on to create a configuration and enable a procedure.
    Remember the stop until the next StartMeasurement().

Testing
=======

Each patch builds with --enable-maintainer-mode and unit/test-rap
passes. The PTS runs (PTS 8.14.0, Qualcomm controller) used a
BlueZ 5.86 based tree carrying these fixes.

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

 client/cs.c                        |  40 +--
 doc/org.bluez.ChannelSounding1.rst |  21 +-
 lib/bluetooth/hci.h                |   1 +
 profiles/ranging/rap.c             |  16 +-
 profiles/ranging/rap_hci.c         | 414 +++++++++++++++++++++++------
 src/device.c                       |   3 +
 src/gatt-database.c                |  25 ++
 src/gatt-database.h                |   2 +
 src/shared/hci.c                   |  12 +-
 src/shared/hci.h                   |   2 +-
 src/shared/rap.c                   |  82 +++++-
 src/shared/rap.h                   |   6 +-
 tools/hcitool.c                    |   3 -
 13 files changed, 484 insertions(+), 143 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2026-11-03 20:38 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02  8:18 [PATCH BlueZ 00/15] Channel Sounding and RAP fixes Cheng Jiang
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-02  8:18 ` [PATCH BlueZ 02/15] shared/rap: Reset the readable Ranging Counters per connection Cheng Jiang
2026-11-02  8:19 ` [PATCH BlueZ 03/15] shared/rap: Subscribe on-demand data with the requested transport Cheng Jiang
2026-11-02  8:19 ` [PATCH BlueZ 04/15] shared/rap: Subscribe to Ranging Data when a measurement starts Cheng Jiang
2026-11-02  8:19 ` [PATCH BlueZ 05/15] client/cs: Fix use-after-free in stop_measurement_reply Cheng Jiang
2026-11-02  8:19 ` [PATCH BlueZ 06/15] shared/hci: Look up the connection handle on the right link Cheng Jiang
2026-11-02  8:19 ` [PATCH BlueZ 07/15] profiles/ranging: Let the Reflector run the CS setup phase Cheng Jiang
2026-11-02  8:19 ` [PATCH BlueZ 08/15] profiles/ranging: Let StartMeasurement() pick the Initiator for Both Cheng Jiang
2026-11-02  8:19 ` [PATCH BlueZ 09/15] profiles/ranging: Take the CS role from Config Complete Cheng Jiang
2026-11-02  8:19 ` [PATCH BlueZ 10/15] profiles/ranging: Act on a CS configuration created by the peer Cheng Jiang
2026-11-02  8:19 ` [PATCH BlueZ 11/15] profiles/ranging: Keep a peer-driven setup from being rewound Cheng Jiang
2026-11-02  8:19 ` [PATCH BlueZ 12/15] profiles/ranging: Defer CS Security Enable until the link is encrypted Cheng Jiang
2026-11-02  8:19 ` [PATCH BlueZ 13/15] profiles/ranging: Choose the CS antenna configuration from both ends Cheng Jiang
2026-11-02  8:19 ` [PATCH BlueZ 14/15] profiles/ranging: Do not start a procedure after StopMeasurement() Cheng Jiang
2026-11-02  8:19 ` [PATCH BlueZ 15/15] shared/rap: Start the Real-time timeout when the procedure starts Cheng Jiang
2026-11-03 20:38 ` [PATCH BlueZ 00/15] Channel Sounding and RAP fixes Luiz Augusto von Dentz

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