From 18660401fc54bff989a558ad4851d9dabd56bfc0 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sun, 20 Jun 2021 19:39:38 +0200 Subject: [PATCH] l2cap: don't trigger hci disconnect if l2cap security requirements are insufficient --- CHANGELOG.md | 1 + src/l2cap.c | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad9922802..3a9ff3673 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - GAP: abort legacy pairing if Level 4 is required - GAP: abort SSP on IO Capabilities Request event if Level 4 is required but SC not supported by remote - GAP: abort SSP on User Confirmation Request event if Level 3 is required but MITM protection not possible +- L2CAP: don't trigger hci disconnect if l2cap security requirements are insufficient ## Release v1.4 diff --git a/src/l2cap.c b/src/l2cap.c index 481b17b8d..a0fa3d6d5 100644 --- a/src/l2cap.c +++ b/src/l2cap.c @@ -1704,10 +1704,6 @@ static void l2cap_run_signaling_response(void) { #ifdef ENABLE_CLASSIC case CONNECTION_REQUEST: l2cap_send_signaling_packet(handle, CONNECTION_RESPONSE, sig_id, source_cid, 0, result, 0); - // also disconnect if result is 0x0003 - security blocked - if (result == 0x0003){ - hci_disconnect_security_block(handle); - } break; case ECHO_REQUEST: l2cap_send_signaling_packet(handle, ECHO_RESPONSE, sig_id, 0, NULL); @@ -2382,8 +2378,10 @@ static void l2cap_handle_security_level(hci_con_handle_t handle, gap_security_le if (actual_level >= required_level){ l2cap_ready_to_connect(channel); } else { - // disconnnect, authentication not good enough - hci_disconnect_security_block(handle); + // security level insufficient, report error and free channel + l2cap_handle_channel_open_failed(channel, L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_SECURITY); + btstack_linked_list_remove(&l2cap_channels, (btstack_linked_item_t *) channel); + l2cap_free_channel_entry(channel); } break;