[PATCH v4 0/4] Bluetooth: find an RPA peer's connection parameters by its identity

From: Radek Podgorny

Date: Tue Nov 24 2026 - 04:31:34 EST


v4 answers Luiz's question on v3 about hci_conn_params_add() resolving
the address before a lookup that resolves it again, and fixes what
Sashiko raised on v3:
https://lore.kernel.org/all/CABBYNZLFtpr8xFjnimRZ9VKOsEgUV-Gzf61bomK4u+SMEyqBxA@xxxxxxxxxxxxxx/
https://sashiko.dev/#/patchset/20261109-for-upstream-le-conn-params-rpa-v3-1-ad1225bb0b8f%40podgorny.cz

The single v3 patch is now four. Patch 4 is the v3 fix itself. The
first three fix bugs in bluetooth-next that it exposes or sits next to,
and each stands on its own:

1. hci_connect_le() keeps pointing into an IRK after leaving RCU.
2. A connect to a peer's RPA misses the connection the peer already
has under its identity and adds a second hci_conn.
3. A second advertising report before LE Create Connection is sent
adds a second hci_conn for a peer dialled under its RPA.
4. The connection is created with the controller-wide defaults instead
of the peer's own parameters.

Patches 3 and 4 use helpers added in patch 2; patch 1 is independent.

Tested on v7.3.5 (the flags tests need &c->flags there) on a Raspberry
Pi CYW43455 central and a peer on a resolvable private address whose
parameters are loaded under its identity: first with three successive
builds of v4 applied as one patch (17 of 17 connects), then with this
series for three days (6 of 6 forced reconnects and 179 connects in
normal use). Every connect was one Create Connection to the RPA,
including across RPA rotations between attempts, and those captured on
air carried the identity's parameters. With the peer connected, an
L2CAP connect to its current or a previous RPA now finds the existing
connection, as one to its identity does; without the changes it adds a
second hci_conn under the RPA and waits until it times out. Not
exercised: a controller that resolves the address itself and a peer
with no cached RPA, which this controller and peer cannot reach, and a
second advertising report before LE Create Connection is sent.

Known limitations, raised by a local Sashiko run and left as they are:

- Patch 3: if an explicit connect was made to a peer's RPA before its
IRK was known, auto-connect to the identity gets -EBUSY until whoever
made that connect cancels it, which for Pair Device is userspace: a
connect that was never started has no timeout. Reusing that
connection instead hands the auto-connect params a reference they do
not own. Avoiding both needs the explicit connect moved to the
identity when the IRK is added, which is a separate change.
- Patch 2: Cancel Pair Device by an RPA no longer finds a pairing
started by that RPA when the IRK was already known. It now behaves as
a pairing started by the identity, which is how bluetoothd starts one
for a peer whose IRK it holds.

Per Documentation/process/generated-content.rst: the patches and this
message were done with the Claude coding assistant (model as in the
Assisted-by trailer). The prompts asked it to fix the issues Sashiko
raised on v2 and v3 and the question raised on v3, then to review the
result with a local run of Sashiko and with Sashiko's published review
prompts, and fix what that turned up. The author directed the work and
reviewed the result.

---
Changes in v4:
- Split into four patches (Sashiko)
- hci_conn_params_add(): resolve once, through a new
__hci_conn_params_lookup() that does not resolve again (Luiz, Sashiko)
- New patch 2, hci_connect_le_scan(): resolve an RPA to the identity
first, so a connect to an RPA neither creates its connection under
the RPA nor misses one the peer already has under its identity
(Sashiko). Add Device, which Sashiko also named, accepts only
identity addresses
- New patch 3, hci_connect_le(): when the lookup by address misses,
find the peer's connection by IRK and refuse it with -EBUSY, also
while scanning, since a scanning one then belongs to other params. A
second advertising report before LE Create Connection is sent no
longer creates a second hci_conn (Sashiko). This replaces v3's reuse
of a scanning connection found by IRK, which patch 2 makes
unnecessary
- New patch 1: copy the RPA dialled out of the IRK under RCU
- Rebased on bluetooth-next
- Link to v3: https://patch.msgid.link/20261109-for-upstream-le-conn-params-rpa-v3-1-ad1225bb0b8f@xxxxxxxxxxx

Changes in v3:
- Look up the identity instead of the RPA, not after it, so an entry
left under the peer's pre-bonding RPA cannot shadow it
- Copy the identity out of the IRK under rcu_read_lock(), since SMP can
free the IRK without hdev->lock
- hci_conn_params_add() stores a new entry under the identity
- load_conn_param() and load_conn_subrate(): look up the connection with
the entry's address type
- hci_connect_le(): find the scanning connection of a connect made to
the peer's RPA by its IRK, so it is not duplicated once the identity
entry is pending, even after the peer has moved to a new RPA, and
also when the controller resolved the advertisement or no RPA is
cached for the peer. Kept in this patch, since on its own it would
leave a reference imbalance until the lookup is fixed
- Rebased on bluetooth-next
- Link to v2: https://patch.msgid.link/20261104120138.1165715-1-radek@xxxxxxxxxxx

Changes in v2:
- Resolve the RPA inside hci_conn_params_lookup() rather than at the
hci_le_create_conn_sync() call site, as Luiz suggested, so no other
caller can miss the entry
- Rebased on bluetooth-next
- Link to v1: https://patch.msgid.link/20261101-for-upstream-le-conn-params-rpa-v1-1-988629a09bc9@xxxxxxxxxxx

---
Radek Podgorny (4):
Bluetooth: copy the peer's RPA out of its IRK under RCU
Bluetooth: connect to an RPA as to the identity behind it
Bluetooth: refuse to dial a peer whose connection is under its RPA
Bluetooth: find an RPA peer's connection parameters by its identity

include/net/bluetooth/hci_core.h | 2 ++
net/bluetooth/hci_conn.c | 75 ++++++++++++++++++++++++++++++++++++++--
net/bluetooth/hci_core.c | 50 ++++++++++++++++++++++++---
net/bluetooth/hci_event.c | 4 +--
net/bluetooth/mgmt.c | 4 +--
5 files changed, 125 insertions(+), 10 deletions(-)
---
base-commit: ffb95458a0f70dcab620eee0ecf5ef7750971b2f
change-id: 20261101-for-upstream-le-conn-params-rpa-f2334fb5dda7

--
Radek Podgorny <radek@xxxxxxxxxxx>