Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bluetooth: host: Failed to set security right after reconnection with bonded Central #45820

Closed
MarekPieta opened this issue May 20, 2022 · 1 comment · Fixed by #45801
Closed
Labels
area: Bluetooth Host Bluetooth Host (excluding BR/EDR) area: Bluetooth bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@MarekPieta
Copy link
Collaborator

Describe the bug
Failed to set security right after reconnection with bonded peer. The failure is caused by inability to find SMP channel. It seems that ATT L2CAP channel tries to send security request before SMP L2CAP channel is initialized.

To Reproduce
The issue can be observed with samples/bluetooth/peripheral_hids sample. Steps to reproduce:

  1. Build and program the peripheral_hids sample.
  2. Connect with device over BLE (e.g. with Android phone) and establish security
  3. Disconnect
  4. Reconnect
  5. Right after reconnection, the information about error is observed in the logs. The error log is observed on every reconnection.

Expected behavior
The SMP channel must be initialized before ATT channel tries to send the security request, so that security request from peripheral would work fine.

Impact
Sending SMP security request by peripheral right after reconnection with bonded peer ends with error. The SMP request is triggered by CONFIG_BT_GATT_AUTO_SEC_REQ which is enabled by default.

Logs and console output
Error log denoting problem:

[00:00:43.157,531] <err> bt_smp: Unable to find SMP channel
[00:00:43.157,562] <wrn> bt_gatt: Failed to set security for bonded peer (-128)

Environment (please complete the following information):
Commit hash: 2dc866fa487ba524b426adc453d028bdd7aaa4e2
Board: nrf52840dk_nrf52840

@MarekPieta MarekPieta added the bug The issue is a bug, or the PR is fixing a bug label May 20, 2022
MarekPieta added a commit to MarekPieta/zephyr that referenced this issue May 20, 2022
The L2CAP channel section is sorted lexicographically. Make sure
that ATT fixed channel will be placed as the last one to ensure
that SMP channel is properly initialized before bt_att_connected
tries to send security request.

Fixes zephyrproject-rtos#45820

Signed-off-by: Marek Pieta <[email protected]>
@alwa-nordic alwa-nordic added area: Bluetooth area: Bluetooth Host Bluetooth Host (excluding BR/EDR) priority: medium Medium impact/importance bug labels May 20, 2022
@alwa-nordic
Copy link
Collaborator

I set this issue to priority medium because @MarekPieta told me it affects a lot of samples in NCS.

carlescufi pushed a commit that referenced this issue May 20, 2022
The L2CAP channel section is sorted lexicographically. Make sure
that ATT fixed channel will be placed as the last one to ensure
that SMP channel is properly initialized before bt_att_connected
tries to send security request.

Fixes #45820

Signed-off-by: Marek Pieta <[email protected]>
jori-nordic pushed a commit to jori-nordic/zephyr that referenced this issue May 25, 2022
The L2CAP channel section is sorted lexicographically. Make sure
that ATT fixed channel will be placed as the last one to ensure
that SMP channel is properly initialized before bt_att_connected
tries to send security request.

Fixes zephyrproject-rtos#45820

Signed-off-by: Marek Pieta <[email protected]>
(cherry picked from commit 903672c)
laxiLang pushed a commit to laxiLang/zephyr that referenced this issue May 30, 2022
The L2CAP channel section is sorted lexicographically. Make sure
that ATT fixed channel will be placed as the last one to ensure
that SMP channel is properly initialized before bt_att_connected
tries to send security request.

Fixes zephyrproject-rtos#45820

Signed-off-by: Marek Pieta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Host Bluetooth Host (excluding BR/EDR) area: Bluetooth bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants