Skip to content

smp: save pairing keys to keystore before draining connection - #1003

Merged
zxzxwu merged 1 commit into
google:mainfrom
zxzxwu:smp-drain-fix
Oct 5, 2026
Merged

zxzxwu merged 1 commit into
google:mainfrom
zxzxwu:smp-drain-fix

Conversation

@zxzxwu

@zxzxwu zxzxwu commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

smp: save pairing keys to keystore before draining connection

In Session.on_pairing(), await self.connection.drain() was placed before
await self.ctkd_task and await self.manager.on_pairing().

When continuous GATT/EATT traffic occurs on the LE link immediately after SMP
key distribution completes, in_flight on the LE connection remains > 0 until
the traffic subsides. Waiting for connection.drain() before calling
manager.on_pairing() delays storing the derived keys (including the CTKD
BR/EDR link key) into the keystore. If the peer initiates a BR/EDR connection
and requests link encryption during this window, Bumble fails to find the link
key in its keystore and replies with HCI_Link_Key_Request_Negative_Reply.

Fix this by updating the keystore and notifying the manager via
await self.manager.on_pairing() before awaiting self.connection.drain() and
resolving self.pairing_result.

In `Session.on_pairing()`, `await self.connection.drain()` was placed before
`await self.ctkd_task` and `await self.manager.on_pairing()`.

When continuous GATT/EATT traffic occurs on the LE link immediately after SMP
key distribution completes, `in_flight` on the LE connection remains > 0 until
the traffic subsides. Waiting for `connection.drain()` before calling
`manager.on_pairing()` delays storing the derived keys (including the CTKD
BR/EDR link key) into the keystore. If the peer initiates a BR/EDR connection
and requests link encryption during this window, Bumble fails to find the link
key in its keystore and replies with `HCI_Link_Key_Request_Negative_Reply`.

Fix this by updating the keystore and notifying the manager via
`await self.manager.on_pairing()` before awaiting `self.connection.drain()` and
resolving `self.pairing_result`.
@zxzxwu
zxzxwu requested a review from barbibulle October 5, 2026 08:29
@zxzxwu

zxzxwu commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

cc @TheArkadiuszGrzelka

@zxzxwu
zxzxwu merged commit 94889eb into google:main Oct 5, 2026
36 checks passed
@zxzxwu
zxzxwu deleted the smp-drain-fix branch October 5, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants